0

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?

1 Answer 1

1

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].

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.