scikit-hep / mplhep

Extended histogram plotting on top of matplotlib and HEP collaboration compatible styling
https://mplhep.readthedocs.io
MIT License
189 stars 66 forks source link

CMS style: add more colors(?) #537

Open magnarex opened 1 week ago

magnarex commented 1 week ago

Hi! So I've just encountered an issue when I try to plot more than 6 stacked histograms, the colors just loop back and the legend becomes kind of useless. I've seen this is because there is only 6 colors defined for the CMS style (in my case).

I'm not sure either where these colors are taken from, so I just restored the rcParamsDefault for axes.prop_cycle. I think it would be really useful if there was a reference to these colors somewhere (or maybe there is and I missed it!).

Thanks in advance! (:

andrzejnovak commented 1 week ago

Hey @magnarex That's about right. You can find the rest of the CMS colors at https://cms-analysis.docs.cern.ch/guidelines/plotting/colors/

You can either apply the colors directly in mpl function calls, but if you prefer to have a standard cycler you can modify the theme like this.

mplhep.style.use(["CMS", {"axes.prop_cycle": cycler("color", ["red", "green", "blue", ... ])} ])

Hope that helps!

magnarex commented 6 days ago

Hi, @andrzejnovak! Thanks for your prompt response.

I couldn't find myself that web, that makes things much more easy (and consistent with the colour scheme in the rest of my plots).

Thanks again! (: