If I have an image, let's say
im = np.ones((10,10))
When I plot this using imshow, everything is dandy:
import matplotlib.pyplot as plt
plt.imshow(im)
plt.show()
What I want is to be able to look at a specific part of the matrix, and keep the axis the same as the indices used to access the matrix
plt.imshow(im[2:5, 5:8])
plt.show()
This should give me a matrix with a y-axis of 5,6,7 and a x-axis of 2,3,4.
Any help?
You want to use the extent
option: plt.imshow(im[2:5, 5:8],extent=[2,4,5,7])
. extent
takes the form of [xmin, xmax, ymin, ymax]
.