Mark,
It sounds like what you want axis('scaled') to do is nothing other than
gca().set_aspect(1, adjustable='box')
draw_if_interactive()
I think this is a bit out of character with things like axis('equal').
Part of this character is that automatic things are turned on, so that
going back and forth between axis('equal') and axis('scaled') switches
back and forth between the same two plots; the result is not
history-dependent.
At your request (between the 0.87.7 and 0.90 releases), I put in a
little bit of history-dependence by making axis('scaled') call to
self.set_autoscale_on(False) # Req. by Mark Bakker
after the set_aspect() call. This means that you can get the behavior
you want simply by changing your example to
from pylab import *
plot([1,2,3],[1,2,1])
axis('scaled')
axis([1,2,1,2]) # define new axis limits
Is this good enough? Do you really need to be able to set the axis
limits *before* the call to axis('scaled')? If so, then I am inclined
to make this a separate option for the axis command, because I think the
present behavior of axis('scaled') is sensible in the context of the
other existing options.
Eric
Mark Bakker wrote:
> Eric -
>
> I just installed version 0.90 on my windows machine and it seems that
> axis('scaled') doesn't work properly yet.
> I thought axis('scaled') will change the axes such that the aspect ratio
> is equal WITHOUT changing the limits on the axes.
> A simple example shows that this goes wrong (I thought this used to work):
>
> from pylab import *
> plot([1,2,3],[1,2,1])
> axis([1,2,1,2]) # define new axis limits
> axis('scaled')
>
> And now Python comes back with ( 1.0, 3.0, 0.80000000000000004, 2.0),
> which are the limits of the original plot command obtained using
> autoscale_view.
> I think this is an easy fix in the axis function of axes.py.
> Here you do an autoscale_view, which shouldn't be done in the 'scaled'
> option.
> I think you only need to change the indicated line below.
>
> Thanks,
>
> Mark
>
> def axis(self, *v, **kwargs):
> '''
> Convenience method for manipulating the x and y view limits
> and the aspect ratio of the plot.
>
> kwargs are passed on to set_xlim and set_ylim -- see their
> docstrings for details
> '''
> if len(v)==1 and is_string_like(v[0]):
> s = v[0].lower()
> if s=='on': self.set_axis_on()
> elif s=='off': self.set_axis_off()
> elif s in ('equal', 'tight', 'scaled', 'normal', 'auto',
> 'image'):
> self.set_autoscale_on(True)
> self.set_aspect('auto')
> if s!= 'scaled': self.autoscale_view() # THIS LINE WAS
> CHANGED BY ADDING THE IF STATEMENT
> self.apply_aspect()
> if s=='equal':
> self.set_aspect('equal', adjustable='datalim')
> elif s == 'scaled':
> self.set_aspect ('equal', adjustable='box', anchor='C')
> self.set_autoscale_on(False) # Req. by Mark Bakker
> elif s=='tight':
> self.autoscale_view (tight=True)
> self.set_autoscale_on(False)
> elif s == 'image':
> self.autoscale_view(tight=True)
> self.set_autoscale_on(False)
> self.set_aspect('equal', adjustable='box', anchor='C')
>
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users