Eric,

I don't see it that way.  Specifying an equal aspect ratio just means
that I want the scaling of the axes to the same.  Then specifying the
data limits gives the overall scaling of the figure effectively.  This
works perfectly well for a single set of axes.  The bounding space is
allotted so that it all works.  The problem only arises when I have the
figures stacked.  Then it seems that the bounding space becomes fixed
for some reason and instead the axis limits are "what gives" instead of
the space around the axes.

By the way, the adjustable='box-forced' option to set_aspect generates
an exception, 
ValueError: adjustable must be "datalim" for shared axes

Jon

On Wed, 2013-03-20 at 11:25 -1000, Eric Firing wrote:
> On 2013/03/20 8:57 AM, Jonathan Slavin wrote:
> > Hi all,
> >
> > I've run across a minor but annoying bug.  It can be demonstrated pretty
> > simply:
> >
> > fig, ax = plt.subplots(2,1,sharex=True,figsize=(7.,7.))
> > fig.subplots_adjust(hspace=0.0)
> > x = 4.25*(np.arange(6.) - 2.5)/10.
> > y =  0.6*x/max(x)
> > ax[0].plot(x,y)
> > ax[0].set_xlim(-1.2,1.2)
> > ax[0].set_aspect('equal')
> > ax[1].plot(x,y)
> > ax[0].set_ylim(-0.6,0.6)
> > ax[1].set_ylim(-0.6,0.6)
> > ax[1].set_aspect('equal')
> > plt.show()
> >
> > The problem is that the y limits on the two plots are slightly different
> > from those set:
> 
> I think the problem is that you are trying to specify too many things: 
> you are specifying the box dimensions when you make the axes, then you 
> are specifying xlim, and then you are specifying ylim, but then you are 
> asking for a 1:1 aspect ratio.  Something has to give!  The aspect ratio 
> handling is designed to provide the specified aspect ratio under a wide 
> range of circumstances, including zooming and panning, and to do that, 
> it has to be able to change something.  You can choose to let the box 
> dimensions be changeable, or the data limits.
> 
> If you want to fix the data limits, then you have to make the box 
> adjustable.  This can cause problems with shared axes, but you can try 
> it with ax[0].set_aspect('equal', adjustable='box-forced').
> 
> Eric
> 
> > ax[1].get_ylim()
> > (-0.61935483870967734, 0.61935483870967734)
> > and doing a set_ylim doesn't have any effect.  This seems to be caused
> > by the set_aspect('equal'), since removing it results in plots with the
> > correct limits -- but aspect that is not quite equal.  It is affected by
> > the figsize parameter in the call to subplots.  It seems I can get the
> > correct y limits and aspect if I keep the set_aspect('equal') and fiddle
> > with the figsize.  But that certainly doesn't seem to be a desirable
> > behavior.  Ideally, the set_ylim (or set_xlim) would be respected as
> > well as the apect ratio and extra blank space around the figure would be
> > added as needed to fit the figsize.
> >
> > By the way, using no figsize argument to subplots results in y limits
> > even smaller than the data limits.  Also, this problem does not occur
> > for single (non-stacked) plots and the use of subplots_adjust also does
> > not seem to affect the problem.  I'm using matplotlib 1.2.0
> >
> > I did notice that this issue is similar to that discussed in this
> > thread:
> > http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg05783.html
> >
> > Regards,
> > Jon
> >
> 
> 
> 

-- 
______________________________________________________________
Jonathan D. Slavin              Harvard-Smithsonian CfA
jsla...@cfa.harvard.edu         60 Garden Street, MS 83
phone: (617) 496-7981           Cambridge, MA 02138-1516
 cell: (781) 363-0035           USA
______________________________________________________________


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to