Home > OS >  How to edit size of axes text size on SHAP depedence plot in Python
How to edit size of axes text size on SHAP depedence plot in Python

Time:10-19

I have used this code: for i in range(len(col_list)):

    shap.dependence_plot(i, shap_values, X.values, feature_names=X.columns, dot_size=10, interaction_index=None, x_jitter=-0.5)

to generate the following SHAP dependence plot:

enter image description here

Does anyone know how to modify the size of the text in the x-axis so that it becomes smaller? For example, 150000 doesn't overlap with 175000...

CodePudding user response:

I'm not familiar with SHAP, but my guess is it looks like it returns a matplotlib Figure object. In that case, the following should work

shap_figure = shap.dependence_plot(i, shap_values, X.values, feature_names=X.columns, dot_size=10, interaction_index=None, x_jitter=-0.5)

ax_list = shap_figure .axes # see https://stackoverflow.com/a/24107230/11148296
ax = ax_list[0]
ax.set_xlabel('Time', fontsize=14)
ax.set_ylabel('Values', fontsize=14)

shap_figure 
  • Related