matplotlib / cheatsheets

Official Matplotlib cheat sheets

Home Page:https://matplotlib.org/cheatsheets/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No pcolormesh referenced

jklymak opened this issue · 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.

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.

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 ;-)

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

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

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