Search code examples
python-3.xshap

How to change the color of bar in shap.plot.bar and shap.plots.waterfalls?


As mentioned in the question, is there anyway we can change color of bar and waterfall plot in shap plot? I didn't see any option to change it. I tried using matplotlib to change the color but that didn't solve the issue. I can add the title but can't change the color. Any help would be great.

plt.title("This is my title")
plt.gray()
shap.plots.bar(shap_values,show = False)
shap.plots.waterfall(shap_values[-1])

plt.show()

Thanks,

Sam


Solution

  • I had a similar issue. I wanted to swap the blue color with the red one in the shap waterfall plot.

    My approach was modifying the file _waterfall.py in the shap lib, replacing the lines with c = colors.red_rgb with c = colors.blue_rgb and vice-versa.

    Surely not an elegant solution but I just needed to generate 6 plots this way.