I’m trying to make a square plot (using imshow), i.e. aspect ratio of 1:1, but I can’t. None of these work:
import matplotlib.pyplot as plt
ax = fig.add_subplot(111,aspect='equal')
ax = fig.add_subplot(111,aspect=1.0)
ax.set_aspect('equal')
plt.axes().set_aspect('equal')
It seems like the calls are just being ignored (a problem I often seem to have with matplotlib).
Third times the charm. My guess is that this is a bug and Zhenya’s answer suggests it’s fixed in the latest version. I have version 0.99.1.1 and I’ve created the following solution:
This is ‘force.png’:

Below are my unsuccessful, yet hopefully informative attempts.
Second Answer:
My ‘original answer’ below is overkill, as it does something similar to
axes.set_aspect(). I think you want to useaxes.set_aspect('auto'). I don’t understand why this is the case, but it produces a square image plot for me, for example this script:Produces an image plot with ‘equal’ aspect ratio:


and one with ‘auto’ aspect ratio:
The code provided below in the ‘original answer’ provides a starting off point for an explicitly controlled aspect ratio, but it seems to be ignored once an imshow is called.
Original Answer:
Here’s an example of a routine that will adjust the subplot parameters so that you get the desired aspect ratio:
This produces a figure like so:

I can imagine if your having multiple subplots within the figure, you would want to include the number of y and x subplots as keyword parameters (defaulting to 1 each) to the routine provided. Then using those numbers and the
hspaceandwspacekeywords, you can make all the subplots have the correct aspect ratio.