## matplotlib-users

 [Matplotlib-users] controlling aspect ratio From: Jochen Voss - 2004-11-01 16:02:25 Attachments: application/pgp-signature ```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 --=20 http://seehuhn.de/ ```
 [Matplotlib-users] controlling aspect ratio From: Michael P. Mossey - 2006-03-02 21:22:31 ```I need to control aspect ratio of the plot as visible on the screen or printed.. for example, a plotted circle or ellipse must come out with the right aspect ratio. (Note: printing is primary, we assume printer pixels are perfectly square, and we don't care if the screen pixels are not quite square.) (Note to John -- I'm in Ted Drain's group at JPL, and I'm looking at this early.. I know you've been hired to create an ellipse primitive.) So what would be a way of controlling aspect ratio? Can this be done via pylab, or better done through the OO interface? I know that I can resize the figure canvas, but to be strictly correct I need to know the length of the axes in pixels, not the figure canvas. Mike ```
 [Matplotlib-users] exact aspect ratio From: Michael P. Mossey - 2006-03-03 20:06:50 ```Hello, I figured out the answer about aspect ratio. I see the method on the axes object. Mike ```
 Re: [Matplotlib-users] controlling aspect ratio From: Cory Davis - 2004-11-01 16:24:54 ```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 cdavis@... cory@... http://www.geos.ed.ac.uk/contacts/homes/cdavis )))))))))))))))))))))))))))))))))))))))))))) ```
 Re: [Matplotlib-users] controlling aspect ratio From: Jochen Voss - 2004-11-01 20:04:04 Attachments: application/pgp-signature ```Hello Cory, On Mon, Nov 01, 2004 at 04:24:34PM +0000, Cory Davis wrote: > I'm not suggesting that this is a good way to to so, but it works (the > last time I tried). Hope this helps. Thank you very much, it works beautifully. All the best, Jochen --=20 http://seehuhn.de/ ```
 Re: [Matplotlib-users] controlling aspect ratio From: Alan G Isaac - 2004-11-01 16:51:07 ```On Mon, 1 Nov 2004, Jochen Voss apparently wrote: > 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? http://sourceforge.net/mailarchive/forum.php?thread_id=5562487&forum_id=33405 hth, Alan Isaac ```
 Re: [Matplotlib-users] controlling aspect ratio From: Jochen Voss - 2004-11-01 20:09:15 Attachments: application/pgp-signature ```Hello Alan, On Mon, Nov 01, 2004 at 11:52:07AM -0500, Alan G Isaac wrote: > http://sourceforge.net/mailarchive/forum.php?thread_id=3D5562487&forum_id= =3D33405 Thanks, this looks incredibly useful. I will have a closer look as soon as I find time. All the best, Jochen --=20 http://seehuhn.de/ ```