I want to add some modifications to my force plot (created by shap.plots.force
) using Matplotlib, e.g. adding title, using tight layout etc. However, I tried to add title and the title doesn't show up. Any ideas why and how can I add the title using Matplotlib?
import numpy as np
import shap
import matplotlib.pyplot as plt
myBaseline=1.5
shap_values_0 = np.array([-1, -4, 3])
test_point_0 = np.array([11, 12, 13])
features_names = ['a1','a2','a3']
shap.plots.force(myBaseline,shap_values_0,test_point_0,features_names,matplotlib = 1)
plt.suptitle("This is my title") # It doesn't show up, why?
fig = plt.gcf()
fig.canvas.draw()
plt.close()
CodePudding user response:
I had to add show=0
at shap.plots.force
, i.e.
shap.plots.force(myBaseline,shap_values_0,test_point_0,features_names,matplotlib = 1, show=0)
I have no idea why it works, but it does.
CodePudding user response: