cheatsheets icon indicating copy to clipboard operation
cheatsheets copied to clipboard

No pcolormesh referenced

Open jklymak opened this issue 3 years ago • 5 comments

Folks should be usingpcolormesh in general rather than imshow - imshow really only works for equally spaced pixels, and there is lots of data that is not laid out that way. However the cheatsheet doesn't mention pcolormesh.

jklymak avatar Mar 14 '21 15:03 jklymak

Cheatsheets are meant to give a quick overview of the main functions and I had to make some choices. Regarding pcolormesh and imshow, I don't know if we have usage statistics but from the gallery, I think there are mostly examples using imshow and not so many using pcolormesh. But I may be wrong.

rougier avatar Mar 17 '21 07:03 rougier

I wouldn't suggest pcolormesh instead of imshow. Perhaps pcolormesh instead of xcorr? xcorr is just a light wrapper around np.correlate and stem.

The point of pcolormesh is that it works properly with unequally spaced x and y. If someone mistakenly uses imshow in that circumstance, their image will be off. imshow also lays things out upside down unless you are explicitly looking at an image. Finally it has the wacky "extent" kwargs which interact so strangely with the limits and the "origin" kwarg that we have to have a whole "intermediate" tutorial to explain it (https://matplotlib.org/stable/tutorials/intermediate/imshow_extent.html)... Of course, the way we implement pcolormesh has its quirks as well ;-)

jklymak avatar Mar 17 '21 14:03 jklymak

I would need to think of an illustrative usage case. From the galley, I found only one.

rougier avatar Mar 17 '21 17:03 rougier

I used the same data that you used for contour in both imshow and pcolormesh. For the pcolormesh, I made dx vary in the x vector, just to show that was possible:

https://github.com/matplotlib/matplotlib/pull/19703/files

jklymak avatar Mar 17 '21 17:03 jklymak

Can't we used a logspace for X and Y with the "default" imshow pattern ? That would be a nice use case.

rougier avatar Mar 19 '21 05:03 rougier