You can do this by manually setting the aspect of the image (or by automatically zooming in).
By default, imshow sets the aspect of the graph to 1, as this is often what people want for image data.
In your case, you can do something like:
import matplotlib.pyplot as plt import numpy as np grid = np.random.random((10,10)) fig, (ax1, ax2, ax3) = plt.subplots(nrows=3, figsize=(6,10)) ax1.imshow(grid, extent=[0,100,0,1]) ax1.set_title('Default') ax2.imshow(grid, extent=[0,100,0,1], aspect='auto') ax2.set_title('Auto-scaled Aspect') ax3.imshow(grid, extent=[0,100,0,1], aspect=100) ax3.set_title('Manually Set Aspect') plt.tight_layout() plt.show()

Joe Kington Nov 15 '12 at 2:36 2012-11-15 02:36
source share