I have a two-dimensional grid data with 10 columns and 100 rows and I am using the imshow command to plot a colormap of the data. Because there are 10 columns and 100 rows I get a rectangular plot, so to get the aspect ratio right, I changed the extent in the command. So my x-axis ranges from 100 to 200 which is what I want but my y-axis ranges from 0 to 100, but I want it to range from 0.0001 to 0.001. How is this possible?
Add a comment
|
1 Answer
You may need to specify the option aspect='auto' to change the aspect ratio.
import matplotlib.pyplot as plt
import numpy as np
data = np.random.random((100, 10))
extent = [0.0001, 0.001, 100, 200]
plt.figure(1)
plt.imshow(data)
plt.figure(2)
plt.imshow(data, extent=extent)
plt.figure(3)
plt.imshow(data, extent=extent, aspect='auto')
plt.show()