## [Matplotlib-users] Squared contour plot

 [Matplotlib-users] Squared contour plot From: Andrea Riciputi - 2005-12-12 16:16:59 ```Hi all, I'm quite new to matplotlib and I'm trying to do some squared contour plots (I mean contour plots with the same scale for both axes). However, any attempt has failed. How can I get a plot with an aspect ratio equals 1? Thanks in advance, Andrea ```

 [Matplotlib-users] Squared contour plot From: Andrea Riciputi - 2005-12-12 16:16:59 ```Hi all, I'm quite new to matplotlib and I'm trying to do some squared contour plots (I mean contour plots with the same scale for both axes). However, any attempt has failed. How can I get a plot with an aspect ratio equals 1? Thanks in advance, Andrea ```
 Re: [Matplotlib-users] Squared contour plot From: Jeff Whitaker - 2005-12-12 17:25:48 ```Andrea Riciputi wrote: > Hi all, > I'm quite new to matplotlib and I'm trying to do some squared contour > plots (I mean contour plots with the same scale for both axes). > However, any attempt has failed. How can I get a plot with an aspect > ratio equals 1? > > Thanks in advance, > Andrea > Andrea: The matplotlib default figure size is not square. To remedy this, you can either edit your .matplotlibrc and set (for example) figure.subplot.left : 0.1 # the left side of the subplots of the figure figure.subplot.right : 0.9 # the right side of the subplots of the figure figure.subplot.bottom : 0.1 # the bottom of the subplots of the figure figure.subplot.top : 0.9 # the top of the subplots of the figure or do the same manually in your script via fig.set_figsize_inches((8,8)) # default is (8,6) You might also have to use the set_xlim and set_ylim axes methods to make sure the axis limits are set to be the same. HTH, -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg ```
 Re: [Matplotlib-users] Squared contour plot From: John Hunter - 2005-12-13 02:50:05 ```>>>>> "Jeff" == Jeff Whitaker writes: Jeff> fig.set_figsize_inches((8,8)) # default is (8,6) Jeff> You might also have to use the set_xlim and set_ylim axes Jeff> methods to make sure the axis limits are set to be the same. You probably also want to look at the "set_aspect" method of the axes, which has received a lot of attention from mark Bakkar. In particular, ax = subplot(111, aspect='equal') should help. With an existing axes instance, ax.set_aspect('equal'). Here is the docstring, since the web site is not updated to the current release yet., def set_aspect(self,aspect='normal',fixLimits=False,alignment='center'): """ Set aspect to 'normal' or 'equal' 'normal' means matplotlib determines aspect ratio 'equal' means scale on x and y axes will be set equal such that circle looks like circle In the future we may want to add a number as input to have a certain aspect ratio, such as vertical scale exagerrated by 2. fixLimits: False means data limits will be changed, but height and widths of axes preserved. True means height or width will be changed, but data limits preserved alignment is 'center' or 'lowerleft', only used when fixLimits is True ACCEPTS: str, boolean, str """ ```
 Re: [Matplotlib-users] Squared contour plot From: Andrea Riciputi - 2005-12-13 08:55:57 ```Thanks to both Jeff and John for your help. Just a further question: what if I want to do contour plot with dashed lines (or any other symbol)? contour(x, y, nu.transpose(z), linestyle = '-', colors = 'r') or contour(x, y, nu.transpose(z), colors = 'r-') don't work. Thanks, Andrea On Dec 13, 2005, at 03:43 , John Hunter wrote: >>>>>> "Jeff" == Jeff Whitaker writes: > > Jeff> fig.set_figsize_inches((8,8)) # default is (8,6) > > Jeff> You might also have to use the set_xlim and set_ylim axes > Jeff> methods to make sure the axis limits are set to be the same. > > You probably also want to look at the "set_aspect" method of the axes, > which has received a lot of attention from mark Bakkar. In > particular, > > ax = subplot(111, aspect='equal') > > should help. > > With an existing axes instance, > > ax.set_aspect('equal'). > > Here is the docstring, since the web site is not updated to the > current release yet., > > def set_aspect > (self,aspect='normal',fixLimits=False,alignment='center'): > """ > Set aspect to 'normal' or 'equal' > > 'normal' means matplotlib determines aspect ratio > > 'equal' means scale on x and y axes will be set equal such > that circle looks like circle > > In the future we may want to add a number as input to have > a certain aspect ratio, > > such as vertical scale exagerrated by 2. > > fixLimits: False means data limits will be changed, but height > and widths of axes preserved. True means height or > width will be changed, but data limits preserved > > alignment is 'center' or 'lowerleft', only used when fixLimits > is True > > ACCEPTS: str, boolean, str > """ ```