New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No native way to change colors for plots such as Waterfall plots #3266
Comments
Seems like there is strong support in the community for this feature request, let's prioritize this for the following release. cc @connortann @dsgibbons |
Thank you, @thatlittleboy , I would love to help if possible on implementing some features, but I don't understand the code structure at all (i haven't digged up much though). If i can help with something, just let me know. Discord: eZWALT |
@CloseChoice , we have two PRs with possible implementations for this feature. I think it's quite an important design choice which direction we set, so I wanted to discuss some ideas with you before deciding how to proceed. Design considerationsSome considerations that come to mind are:
In terms of functionality, we might want to be able to set a global "style" that is persistent and will affect every plot they create. Option 1: Config options for each plotI think a config dataclass makes sense for a single plot, as in #3377. However, I'm a bit concerned that it could rather messy if we extend this to handle other plots. It becomes a bit tricky if we want to re-use certain parameters between plots, as it looks like each plot might have its own set of config options. Moreover, there is a really large number of possible style options, from fonts, text sizes, tick sizes, and so on. Some options would probably be shared between plots, whereas others are plot-specific. If our config dataclass accounted for every customisable option, they might become quite large and bloated. Another difficulty is that it pollutes the signature of the plotting functions, as this config object has to be passed to each plot. Option 2: matplotlib's rcParamsWhat do you think about using the matplotlib From the matplotlib docs:
Seaborn offers a high-level API that uses this system, e.g. sns.set_style. Seaborn has high-level functions which internally change the matplotlib rcParams object:
To my mind, the advantage of using this kind of config system would be:
|
I note that matplotlib does not allow us to define custom parameters, as far as I can see. So, we could either to make use of existing settings, or perhaps create our own rcParams singleton. As inspiration, I note that another plotting library ArviZ implemented a rcParams system that follows the behaviour of matplotlib. We could perhaps take that as inspiration: |
@connortann Option 1: Config options for each plot
Option 2: some sort of rcParams
Why don't we go for a dataset class-ish solution where we initialize the dataclass values with settings from |
Related to the rcParams discussion: #1430 |
I found quite a few issues from the past few years relating to the plotting API. I created a label "visualisation" to track these, and a "meta-issue" to discuss the over-arching effort: #3411 One thing that strikes me is that there is a desire not just to be able to customise elements such as colours, but also to have consistency between plots in things such as fonts, tick params & spines. I also think having separation of concerns is going to be really important, as I can see this getting very complex very quickly. So, how about a hybrid approach of the options above: custom style options, implemented as a global setting or context manager? Inspired by seaborn's example, the API could be like this: # Global settings
shap.plots.set_style(...)
shap.plots.bar(shap_values)
shap.plots.beeswarm(shap_values)
# Or as a context manager
with shap.plots.set_style(...):
shap.plots.bar(shap_values) |
@connortann This looks like a good approach to me. I think we might need a prototype for this and then decide on how to roll this out for other plots. |
|
Problem Description
Hello, i've been using shap plots for a while and i've always had the same problem. Most plots have cmap parameter for changing the colors, but some of them , like
shap.plots.waterfall
andshap.plots.bar
doesn't have support and i've really tried to edit things, and to some extent i've figured out a work-around to change the main colors. But there's no way to change things like text-color, edge-color (Which is pretty relevant , cause even if you change the main color, the border is still red) and other details. I suggest that a new parameter is introduced and colors are parametrized. Thank you!Alternative Solutions
This is a workaround to change colors, but it doesn't work if you change the positive colors to other color than red because the edgecolor is still red
Additional Context
No response
Feature request checklist
The text was updated successfully, but these errors were encountered: