Hi there,
I'm not suggesting that this is a good way to to so, but it works (the
last time I tried). Hope this helps.
def setDataAspectRatioByFigSize(ax,r):
"""Same idea as matlab. Adjusts the figure size to fix the aspect
ratio"""
xlim=ax.get_xlim()
dxlim=xlim[1]-xlim[0]
ylim=ax.get_ylim()
dylim=ylim[1]-ylim[0]
pos=ax.get_position()
dxpos=pos[2]
dypos=pos[3]
f=gcf()
figsize=f.get_size_inches()
dxfig=figsize[0]
dyfig=dylim*dxpos*dxfig/r/dypos/dxlim
f.set_figsize_inches(dxfig,dyfig)
def setDataAspectRatioByAxisPos(ax,r):
"""Same idea as matlab. Adjusts the axis position to fix the aspect
ratio"""
xlim=ax.get_xlim()
dxlim=xlim[1]-xlim[0]
ylim=ax.get_ylim()
dylim=ylim[1]-ylim[0]
pos=ax.get_position()
dxpos=pos[2]
dypos=pos[3]
centreypos=pos[1]+0.5*dypos
f=gcf()
figsize=f.get_size_inches()
dxfig=figsize[0]
dyfig=figsize[1]
dypos=dylim*dxpos*dxfig/r/dyfig/dxlim
ax.set_position([pos[0],centreypos-0.5*dypos,dxpos,dypos])
Cheers,
Cory
On Mon, 2004-11-01 at 16:02, Jochen Voss wrote:
> Hello,
>
> I would like to (mis-)use matplotlib to draw some things which
> are not graphs of functions. For this it would be nice to
> be able to fix the aspect ratio of the figure to 1. What is
> a good way to do so?
>
> Jochen
--
))))))))))))))))))))))))))))))))))))))))))))
Cory Davis
Meteorology
School of GeoSciences
University of Edinburgh
King's Buildings
EDINBURGH EH9 3JZ
ph: +44(0)131 6505092
fax +44(0)131 6505780
cd...@st...
co...@me...
http://www.geos.ed.ac.uk/contacts/homes/cdavis
))))))))))))))))))))))))))))))))))))))))))))
|