Agree with Eric. I guess if you remove sharex=True, it will work.

Chao

On Wed, Mar 20, 2013 at 10:27 PM, Eric Firing [via matplotlib] <
ml-node+s1069221n40690...@n5.nabble.com> 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@.../msg05783.html<http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg05783.html>
> >
> > Regards,
> > Jon
> >
>
>
> ------------------------------------------------------------------------------
>
> 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
> [hidden email] <http://user/SendEmail.jtp?type=node&node=40690&i=0>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://matplotlib.1069221.n5.nabble.com/set-limits-not-obeyed-for-stacked-plots-when-set-aspect-equal-used-tp40689p40690.html
>  To start a new topic under matplotlib - users, email
> ml-node+s1069221n...@n5.nabble.com
> To unsubscribe from matplotlib, click 
> here<http://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2&code=Y2hhb3l1ZWpveUBnbWFpbC5jb218MnwxMzg1NzAzMzQx>
> .
> NAML<http://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************




--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/set-limits-not-obeyed-for-stacked-plots-when-set-aspect-equal-used-tp40689p40691.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
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