Following up on this, I’d like to complain about set_aspect()…

If I do:

import matplotlib.pyplot as plt
fig, axes = plt.subplots(nrows=2,sharex=True)
axes[0].set_ylim(0,1.)
axes[0].set_aspect(1.)
plt.show()

the x-axis goes from 0. to 1., but axes[0]’s y-axis goes from 0.32 to 0.67.  
Swapping the order of the y_lim call doesn’t help.  This is very un-intuitive, 
as I’d expect set_ylim() to set what data I see no matter what else is 
happening w/ the plot.

I see that 
axes[0].set_aspect(1.,adjustable=‘box-forced’)
will give the desired behaviour, but I really think it should be the default, 
not adjustable=‘datalim'.  I had no idea set_aspect() had this parameter until 
today, and have had several cursing matches with set_aspect as it kept changing 
my explicitly set data limits. set_ylim() should set the y limits.   

Just my opinion.  Maybe there is a reason for the default, but I really think 
the data view should be prioritized over the shape of the axis.

Thanks,   Jody


> On 8 Apr 2015, at  5:53 AM, Thomas Caswell <tcasw...@gmail.com> wrote:
> 
> What version had this behavior?  I recall some work on how aspect worked, but 
> not exactly what we did.  I see why it is useful, but on the other hand that 
> sort of coupling seems like could cause some trouble if we are not careful.  
> This all come back to we need a real layout manager/constraint solver (which 
> no one has yet had time to address).
> 
> For now I think this will do what you want:
> 
> import numpy as np
> import matplotlib.pyplot as plt
> from mpl_toolkits.axes_grid1 import make_axes_locatable
> 
> fig, ax_top = plt.subplots()
> ax_top.set_aspect(1)
> divider = make_axes_locatable(ax_top)
> bax_bottom = divider.append_axes('bottom', 1, pad=0.1,
>                                          sharex=ax_top)
> 
> 
> Please don't use `plt.setp`, it is a MATLABism that I think is past it's time.
> 
> On Wed, Apr 8, 2015 at 8:21 AM Mark Bakker <mark...@gmail.com 
> <mailto:mark...@gmail.com>> wrote:
> import matplotlib.pyplot as plt
> %matplotlib qt
> fig, axes = plt.subplots(nrows=2,sharex=True)
> plt.setp(axes[0], aspect=1.0, adjustable='box-forced')
> plt.show()
> 
> This used to create two axes of the same horizontal size. What it does now is 
> that it scales the upper axis so that the aspect=1.0 by changing the physical 
> size of the axis. But the physical size of the lower axis is not changed, 
> while this used to be the case in the past (but that may have been a few 
> years back). That sure used to be the desired behavior.
> 
> Thanks for your help,
> 
> Mark
> 
> 
> 
> On Wed, Apr 8, 2015 at 2:16 PM, Thomas Caswell <tcasw...@gmail.com 
> <mailto:tcasw...@gmail.com>> wrote:
> Can you please provide a minimal, but complete and runnable example of what 
> you are doing?
> 
> 
> On Wed, Apr 8, 2015, 08:13 Mark Bakker <mark...@gmail.com 
> <mailto:mark...@gmail.com>> wrote:
> Thanks, Thomas.
> 
> That works indeed, but it doesn't make the figure adjustable, which is what I 
> wanted (that the physical size of the axes changes while the aspect ratio is 
> fixed to 1). I guess that functionality has been taken out. 
> 
> Mark
> 
> On Wed, Apr 8, 2015 at 12:50 PM, Thomas Caswell <tcasw...@gmail.com 
> <mailto:tcasw...@gmail.com>> wrote:
> What are the data limits you are using?
> 
> I suspect they you are over constraining the system/order of operations 
> issue. Try dropping the adjustable setting and pre setting both the data 
> limits and the approximate size in figure fraction (ex via grid spec) of the 
> axes.
> 
> Tom
> 
> 
> On Tue, Apr 7, 2015, 15:54 Mark Bakker <mark...@gmail.com 
> <mailto:mark...@gmail.com>> wrote:
> Hello list,
> 
> I want to axes above each other. They share the x-axis. The top figure has 
> 'aspect=1' (it is a map), the bottom figure shows a cross-section along a 
> horizontal line on the map, so it doesn't have 'aspect=1'. When I do this 
> with code, for example like this:
> 
> fig, axes = plt.subplots(nrows=2,sharex=True)
> plt.setp(axes[0], aspect=1.0, adjustable='box-forced')
> 
> then the physical size of the top axes is much sorter than the physical size 
> of the bottom axes (although they are poperly linked, as they have the same 
> data limit, and when zooming in the top figure, the bottom figure adjusts). 
> It just looks weird, as the size of the horizontal axis of the bottom figure 
> should have the same physical size as the horizontal axis of the top figure. 
> This used to be possible (a few years ago; haven't tried it for a while). Is 
> there a way to do it with the current matpotlib? (1.4.3)
> 
> Thanks,
> 
> Mark
> ------------------------------------------------------------------------------
> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
> Develop your own process in accordance with the BPMN 2 standard
> Learn Process modeling best practices with Bonita BPM through live exercises
> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- 
> <http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-> event?utm_
> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF_______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net 
> <mailto:Matplotlib-users@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users 
> <https://lists.sourceforge.net/lists/listinfo/matplotlib-users>
> 
> 
> ------------------------------------------------------------------------------
> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
> Develop your own process in accordance with the BPMN 2 standard
> Learn Process modeling best practices with Bonita BPM through live exercises
> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF_______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Jody Klymak    
http://web.uvic.ca/~jklymak/





------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to