It would be very great to be able to save a plot produced in summary_plot function.
It is just a matplotlib plot, so you if you pass show=False you can keep manipulating the figure:
shap.summary_plot(shap_values, X, show=False)
import matplotlib.pyplot as pl
pl.savefig("summary_plot.pdf")
how to save the shap_values in csv file? Thanks
It is just a matplotlib plot, so you if you pass
show=Falseyou can keep manipulating the figure:shap.summary_plot(shap_values, X, show=False) import matplotlib.pyplot as pl pl.savefig("summary_plot.pdf")
It doesnt work for me. When I set "show = False", it still plots an image. Can you suggest some ways to fix this. Thanks
@vivitar123 they are just a numpy array so numpy.savetxt will work.
@chaupmcs Perhaps you have defined inline display for matplotlib already in your notebook somewhere? If you did that then plots will display even without a call to show().
Thanks @slundberg
You're right. Removing the "inline display" fixes the saving image problem.
Thanks again for your help.
Seems counterintuitive that a plot function would (by default) not allow an immediately-following call to pyplot.savefig() to work. I'd prefer show=False to be the default, and/or make sure to document how to save visualizations from the package.
From my understanding of the source code it seems for most calls of summary_plot it returns nothing.
Could it not return the figure instance? As well as allowing saving following a show() call it could also allow customisation of the figure.
Most helpful comment
It is just a matplotlib plot, so you if you pass
show=Falseyou can keep manipulating the figure: