|
From: Michael D. <md...@st...> - 2008-02-11 13:35:29
|
Before I look into this further: what version of mpl are you using?
Mark Bakker wrote:
> I seem to have tracked down the problem.
> After calling the aspect_ratio function, the data limits don't get set.
> When a new axis with sharex is called, it gets the old data limits.
> After I call draw() or ax.draw() the datalimit gets set correctly.
> And creating a subplot with sharex works fine.
> Maybe the datalimit needs to be set at the end of the aspect_ratio function?
> (I presume that is part of the draw() command)
> Mark
>
> from pylab import *
>
> x,y = meshgrid(linspace(0,5,5),linspace(0,5,5))
>
> figure()
> ax = subplot(211)
> ax.contour(x,y,x)
> ax.set_aspect('equal',adjustable='datalim')
> print ax.get_xlim() # Prints 0 to 5 while datalimit is much larger
> draw()
> print ax.get_xlim() # Now datalimit is correct and sharex works
> ax2 = subplot(212,sharex=ax)
> draw()
>
> On Feb 11, 2008 9:56 AM, Mark Bakker <ma...@gm...
> <mailto:ma...@gm...>> wrote:
>
> Hello -
>
> I have a hard time getting aspect_ratio to work correctly with sharex.
> This used to work quite a while ago, and has been broken for a long
> time (or at least I don't know how to get it to work)
> But I finally found the time to put a simple example together to
> determine if I do something wrong, or whether this can be fixed easily.
>
> When I make a small contour plot setting the aspect ratio equal
> works fine:
>
> from pylab import *
>
> x,y = meshgrid(linspace(0,5,5),linspace(0,5,5))
>
> figure()
> ax = subplot(211)
> ax.contour(x,y,x)
> ax.set_aspect('equal',adjustable='datalim')
> draw()
>
> Note that the datalim on the x-axis is expanded, as the data limit
> on the y-axis is the determining factor.
>
> If I now try to do the same thing while linking the x-axis of a
> second subplot to the first one, then
> the same call to set_aspect changes the data limit on the y-axis
> while keeping the x-axis fixed.
> That seems inconsistent and is not the behavior I want:
>
> figure()
> ax = subplot(211)
> ax.contour(x,y,x)
> ax2 = subplot(212,sharex=ax)
> ax.set_aspect('equal',adjustable='datalim')
> draw()
>
> Any idea what I am doing wrong?
>
> Thanks, Mark
>
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
|