I think you can do this with a combination of careful control of the size of your axes (as part of the figure), ax.set_xlim and fig.set_size_inches (doc) to set the actual size of the figure.
ex
fig = plt.figure() ax = fig.add_axes([0,0,1,1]) ax.set_xlim([0,N]) fig.set_size_inches([N/2.54,h])
source share