On 2013/03/07 12:24 PM, Jody Klymak wrote:
> Hi All,
>
> I want to have two axes have the same xlimits and the same length of the x 
> axis.  However, I'd also like for the first axis to be plotted at a certain 
> aspect ratio (its geographic if anyone is interested).
>
> The following two tries do not work, because the "bounds" stay the same after 
> set_aspect.
>
> I'm sure I'm just missing some other call to the axes (or axis?) class.  Is 
> there someway at getting at the underlying length of the actual axis, not its 
> whole bounding box?
>

I think there is a simpler way.  Does this do what you want?

fig, axs = plt.subplots(nrows=2, sharex=True)
axs[0].set_aspect(0.7, adjustable='datalim')
axs[0].plot(np.random.rand(5))
axs[1].plot(np.random.rand(7))
plt.show()

Note that when you set the aspect, it is not applied until there is a 
draw() operation.

Eric

> Thanks,   Jody
>
> # this basically has no effect....
> ax=subplot(2,1,1)
> plot(arange(0,10),arange(0,10)*3)
> ax.set_aspect(0.7)
> pp = ax.get_position().bounds
>
> axn=subplot(2,1,2)
> plot(arange(0,10),rand(10))
> ppn = axn.get_position().bounds
> print pp
> print ppn
> axn.set_position([pp[0],ppn[1],pp[2],ppn[3]])
>
> # Or, this zooms in on subplot 1, which is of course not what I want....
>
> ax=subplot(2,1,1)
> plot(arange(0,10),arange(0,10)*3)
> ax.set_aspect(0.7)
> pp = ax.get_position().bounds
>
> axn=subplot(2,1,2,sharex=ax)
> plot(arange(0,10),rand(10))
> ppn = axn.get_position().bounds
> print pp
> print ppn
> axn.set_position([pp[0],ppn[1],pp[2],ppn[3]])
>
>
> --
> Jody Klymak
> http://web.uvic.ca/~jklymak/
>
>
>
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to