ProjectPythia/pythia-foundations

Matplotlib content on setting consistent colorbars

Closed this issue ยท 8 comments

Producing two (or more) contour or pcolor plots of different arrays but with the same colorscale (for fair comparison) is something that comes up very frequently but isn't always obvious how to do with matplotlib.

I think our tutorials should have a simple example for how to achieve this, probably in the first intro notebook.

We have examples of more advanced colorbar control, but I think there's a gap on this important day-to-day plotting need.

@hCraker has built a nice short Cookbook on this topic now visible at https://cookbooks.projectpythia.org/mpl-colorbar-cookbook

Question: does it make more sense to keep this content in a free-standing Cookbook, or integrate into our basic Matplotlib tutorials here in Foundations?

clyne commented

Great question. I think we still struggle with defining what is and what is not a cookbook. But given the focus of the colorbar cookbook on using matplotlib, and its generality to all users, I guess I'd say Foundations would be a better fit for it. Is it worth the effort to move it? Not sure. At the very least it would be good to link to it from the Foundations material.

ktyle commented

I think it would be a valuable component of the Foundations' matplotlib content ...

Great question. I think we still struggle with defining what is and what is not a cookbook. But given the focus of the colorbar cookbook on using matplotlib, and its generality to all users, I guess I'd say Foundations would be a better fit for it. Is it worth the effort to move it? Not sure. At the very least it would be good to link to it from the Foundations material.

While we haven't settled on a complete definition, the majority of the cookbooks have multiple pages and are longer than the foundation notebooks. Cookbooks also cover more niche topics. I would say the topic of the cookbook I made is general enough and covered in a sufficiently small tutorial that it would belong in foundations rather than cookbooks. For consistency and user ease for finding information, it's worth moving this notebook.

Agreed! I think it's a Foundational topic.

The alternative would be to plan to develop a longer series of "specialized" matplotlib lessons to house in the Cookbook, but there are many other places online to find such lessons.

It should be a relatively easy lift to move the Colorbars notebook and integrate it into Foundations.

It looks like the foundations page already talks about shared colorbars and choosing accessible colormaps. Do we even need my notebook? I didn't go into much more detail thank what's already shown on the foundations pages.

Looking through that, it could certainly use some more explanation about the role of Normalize in controlling the range of the colormapping and keeping things common between multiple plots.

I'll open a PR to merge the existing shared colorbar content with what's in my cookbook. @dopplershift thanks for pointing out the need for more instruction on using Normalize. I'll include that as well