Take the 2-minute tour ×

I have a plot of two boxplots in the same figure. Due to style reasons, the axis should have the same length, so that the graphic box is squared. I tried to use the set_aspect method, but the axis are too different by means of range and the result is terrific.

Is it possible to have 1:1 axis even if they have not the same number of points ?



share|improve this question

3 Answers 3

Try axis('equal'). It's been a while since I worked with matplotlib, but I seem to remember typing that command a lot.

share|improve this answer

You can use Axes.set_aspect to do this if you set the aspect to the ratio of axes limits. Here's an example: alt text

from matplotlib.pyplot import figure, show

fig = figure()

ax0 = fig.add_subplot(1,2,1)
ax0.set_xlim(10., 10.5)
ax0.set_ylim(0, 100.)

ax1 = fig.add_subplot(1,2,2)
ax1.set_xlim(0., 1007)
ax1.set_ylim(0, 12.)
x0, x1 = ax1.get_xlim()
y0, y1 = ax1.get_ylim()



share|improve this answer
That is a good starting point. Thanks! –  Vic Podestà Oct 2 '09 at 0:33
You're welcome. –  tom10 Oct 2 '09 at 2:28

For loglog plots ( loglog() ) don't forget to use

share|improve this answer

Your Answer

