Third time charm. I assume this is a mistake, and Eugene's answer suggests that it is fixed in the latest version. I have version 0.99.1.1 and I created the following solution:
import matplotlib.pyplot as plt import numpy as np def forceAspect(ax,aspect=1): im = ax.get_images() extent = im[0].get_extent() ax.set_aspect(abs((extent[1]-extent[0])/(extent[3]-extent[2]))/aspect) data = np.random.rand(10,20) fig = plt.figure() ax = fig.add_subplot(111) ax.imshow(data) ax.set_xlabel('xlabel') ax.set_aspect(2) fig.savefig('equal.png') ax.set_aspect('auto') fig.savefig('auto.png') forceAspect(ax,aspect=1) fig.savefig('force.png')
This is "force.png": 
Below are my unsuccessful, but hopefully informative attempts.
Second answer:
My "original answer" below is redundant as it does something similar to axes.set_aspect() . I think you want to use axes.set_aspect('auto') . I donβt understand why this is so, but for me I get a square graph of the image, for example, this script:
import matplotlib.pyplot as plt import numpy as np data = np.random.rand(10,20) fig = plt.figure() ax = fig.add_subplot(111) ax.imshow(data) ax.set_aspect('equal') fig.savefig('equal.png') ax.set_aspect('auto') fig.savefig('auto.png')
Produces graphics images with an equal aspect ratio:
and one with the format "auto": 
The code below in the "original answer" provides a starting point for an explicitly controlled aspect ratio, but it seems to be ignored after calling imshow.
Original answer:
Here is an example of a procedure that will adjust the subtask settings to get the desired aspect ratio:
import matplotlib.pyplot as plt def adjustFigAspect(fig,aspect=1): ''' Adjust the subplot parameters so that the figure has the correct aspect ratio. ''' xsize,ysize = fig.get_size_inches() minsize = min(xsize,ysize) xlim = .4*minsize/xsize ylim = .4*minsize/ysize if aspect < 1: xlim *= aspect else: ylim /= aspect fig.subplots_adjust(left=.5-xlim, right=.5+xlim, bottom=.5-ylim, top=.5+ylim) fig = plt.figure() adjustFigAspect(fig,aspect=.5) ax = fig.add_subplot(111) ax.plot(range(10),range(10)) fig.savefig('axAspect.png')
The result is this figure: 
I can assume that if you have several subplots in the figure, you would like to include the number of subplots y and x as keyword parameters (default is 1 by default) in the provided procedure. Then, using these numbers and the hspace and wspace , you can make all the subheadings have the correct aspect ratio.