Sorry if this is a silly question; i couldn't find the

> answer in the source files or the mailing list archive.

> I am using matplotlib 0-60.2. Is there an equivalent in

> matplotlib to the matlab command 'axis square', to set

> the aspect ratio to 1? More generally, can i set the

> aspect ratio to any ratio i like? I am interested in

> this for plot() and scatter().

There is no axis square at the moment (easy to add though). But yes,

you can set the axes to any aspect ratio you want. Rather than

calling 'subplot', call 'axes'.

# left, bottom, width, height

axes([0.15, 0.15, 0.7, 0.7])

The numbers are fractions of the figure size. So left is 0.15*figure

width, bottom is 0.15 * figure height, width is 0.7 * figure width and

height is 0.7 * figure height. See

http://matplotlib.sourceforge.net/matplotlib.matlab.html#-axes for

more info.

You can control the figure dimensions using the figsize argument (args

in inches, my apologies)

# figure is 6 inches square

figure(1, figsize=(6, 6))

See http://matplotlib.sourceforge.net/matplotlib.matlab.html#-figure.

Here is and example script

from matplotlib.matlab import *

side = 7 # side of square in inches

figure(1, figsize=(side, side))

# left, bottom, width, height

axes([0.15, 0.15, 0.7, 0.7])

N = 500 # number of scatter points

scatter(rand(N), rand(N)) # should be square

savefig('test.ps')

show()

That said, there is a very important caveat. This probably won't

appear square on your monitor because the dots per inch on your

monitor likely differ in the horizontal and vertical directions (it

should be square if you save as *.ps and print it on a postscript

printer). When I implemented freetype fonts for matplotlib, I asked

on this list if anyone was interested in matplotlib supporting dpi in

the x and y direction so that you could actually create figures in

true sizes on the monitor, but there was no interest at the time. The

freetype lib supports horizontal and vertical dpi, which is why it

came up at the time.

JDH