ProjectPythia / pythia-foundations

Jupyterbook source for the Foundations collection
http://foundations.projectpythia.org
Apache License 2.0
59 stars 42 forks source link

Matplotlib content on setting consistent colorbars #276

Closed brian-rose closed 1 year ago

brian-rose commented 2 years ago

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.

brian-rose commented 2 years ago

@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 2 years ago

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 2 years ago

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

hCraker commented 2 years ago

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.

brian-rose commented 2 years ago

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.

hCraker commented 2 years ago

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.

dopplershift commented 2 years ago

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.

hCraker commented 2 years ago

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