Для этой цели приведена следующая часть кода:
Код: Выделить всё
plt.figure()
fig, ax = plt.subplots()
fig.tight_layout(pad=7.0)
shap.plots.waterfall(val[26], show=False)
for text in ax.texts:
text.set_color('k')
value = float(text.get_text())
text.set_text(f"{value:.{4}f}")
fig, ax = plt.gcf(), plt.gca()
ax.grid(axis='y', color='grey', linestyle=':', linewidth=1, alpha=0.5)
for tick in ax.get_xticklabels():
tick.set_fontname('Times New Roman')
tick.set_fontsize(14)
tick.set_color('k')
for tick in ax.get_yticklabels():
tick.set_fontname('Times New Roman')
tick.set_fontsize(14)
tick.set_color('k')
ax.spines["top"].set_visible(True)
ax.spines["top"].set_color('k')
ax.spines["left"].set_visible(True)
ax.spines["left"].set_color('k')
ax.spines["right"].set_visible(True)
ax.spines["right"].set_color('k')
plt.show()
Код: Выделить всё
for text in ax.texts:
value = float(text.get_text())
text.set_text(f"{value:.{4}f}")
Код: Выделить всё
from decimal import getcontext
getcontext().prec = 4

Подробнее здесь: https://stackoverflow.com/questions/793 ... rfall-plot