Marses
Marses

Reputation: 1572

How to plot an imshow or matshow in logarithmic axis, so that the grid is regular in the logarithmic axis

I want to plot a grid like so:

im = ax.matshow(value_array, origin='lower', extent=[0, xmax, 0, ymax])
ax.set_xscale('log')

So that the x scale is logarithmic, but the grid is regular. At the moment, the grid gets predictably stretched out (i.e it's regular in real units of x, but in the plot the pixels gets more and more compressed as you increase x). Is there an easy way to do this?

Upvotes: 0

Views: 422

Answers (1)

Marses
Marses

Reputation: 1572

Well, I'm going to answer my own question since I figured out what to do.

It doesn't work with imshow or matshow, you have to use pcolormesh and enter the grid boundaries directly.

See link: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.pcolormesh.html

Upvotes: 1

Related Questions