scikit-hep / cabinetry

design and steer profile likelihood fits
https://cabinetry.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
26 stars 21 forks source link

Histogram colors in stacks - user interface creation #381

Closed pariRieck closed 1 year ago

pariRieck commented 1 year ago

Hi! It would be great to set colors of histograms in data / MC stack plots as soon as those are created . Maybe a good way to do it is to add an argument to the function call, namely a dictionary like {sample name: color} ?

alexander-held commented 1 year ago

cc @andrzejnovak who may also have ideas / input here.

In addition to this it seems useful to not override custom rcParams set by users via the mpl.style.use calls in cabinetry but instead only update values that correspond to the matplotlib default. Then users could do something like

import matplotlib as mpl
mpl.rcParams['axes.prop_cycle'] = mpl.cycler(color=["salmon", "tan", "mediumseagreen"])

to get a custom color scheme.

alexander-held commented 1 year ago

Another idea: new setting style with default style="cabinetry" that will apply the mpl.style.use call, and the option style=None that will skip it. That allows users to set rcParams in any way they want. Some other styling operations like tick label design and such can probably also be factored from the code and put into a style sheet gathering everything.

rmnmllr commented 1 year ago

I may have a very small input here since this is about histogram colours:

I noticed that with more than 5 systematics there will be a repetition of colours of the default style MPL_STYLE = "seaborn-v0_8" in cabinetry.visualize.data_mc. The signal has the same colour than the last systematic added. I fixed it for the moment by setting MPL_STYLE = "seaborn-v0_8-notebook"

alexander-held commented 1 year ago

Hi @rmnmllr, thanks for bringing that up. I picked the seaborn-colorblind style by default in an attempt to make the figures more accessible for those with color blindness. I believe the number of different colors that can still easily be distinguished in such an accessible palette is fairly limited. Unfortunately it can be common to have more samples than colors available (I think it is six different ones in the style), so I hope for those cases it will be easy enough to define a custom pallet (or allow using an existing one externally like in your case, but without having to edit cabinetry code directly).

alexander-held commented 1 year ago

399 adds support for custom histogram colors per sample in visualize.data_mc. Please give it a try and let me know if you see any issues with this or have further suggestions about the interface!

alexander-held commented 1 year ago

This will be closed via #399, the remaining ideas (rcParams / style) will be tracked via #265.