0

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?

1 Answer 1

1

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()
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.