I have below plot my data is 2D array from range 0 to 10 but I want my plot's axis be between [0,1] how can I change the scale? besides how can I upside down Y axis?
mydata = np.zeros((10,10))
#fill mydata
im = plt.imshow(mydata,interpolation='bilinear', aspect='auto')
plt.colorbar(im, orientation='vertical')
plt.show()
extent
should be passed a 4-tuple or list with the following
meaning: extent=(xmin, xmax, ymin, ymax)
.y-axis
can be inverted by passing origin='lower'
to imshow
.import numpy as np
import matplotlib.pyplot as plt
mydata = np.random.random((10,10))
im = plt.imshow(mydata,interpolation='bilinear', aspect='auto',
origin='lower', extent=[0, 1, 0, 1])
plt.colorbar(im, orientation='vertical')
plt.show()
Another way to invert the yaxis is to call ax.invert_yaxis
. See (here) and (here) for examples.