Trying to set a maximum value for my plot
Question:
How to set a maximum value for my partial dependance plot? When I set the limit for the x axis it works, but it doesn’t for the y axis, why?
Similar posts I looked at: Limit axis range on pdp plot in python
shap.partial_dependence_plot(
"fc", model.predict, X100, ice=False, show=False,
model_expected_value=True, feature_expected_value=True, ylabel="R")
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
#ax = plt.gca()
#ax.set_ylim([0, 600])
plt.rcParams["figure.dpi"] = 90
plt.xlim(0, 600)
plt.ylim(0, 600)
plt.show()
Answers:
shap.dependence_plot
seems to return a plot object but you store it no where, right ? If so, that’s probably why you can’t set the limit for the y-axis (since the plot isn’t available yet!). I suggested you to do so :
fig, ax = shap.partial_dependence_plot( # <- storing the plot in ax
"fc", model.predict, X100, ice=False, show=False,
model_expected_value=True, feature_expected_value=True, ylabel="R")
plt.rcParams["figure.dpi"] = 90
ax.set_xlim(0, 600) # <- changed plt by ax
ax.set_ylim(0, 600) # <- changed plt by ax
plt.show()
How to set a maximum value for my partial dependance plot? When I set the limit for the x axis it works, but it doesn’t for the y axis, why?
Similar posts I looked at: Limit axis range on pdp plot in python
shap.partial_dependence_plot(
"fc", model.predict, X100, ice=False, show=False,
model_expected_value=True, feature_expected_value=True, ylabel="R")
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
#ax = plt.gca()
#ax.set_ylim([0, 600])
plt.rcParams["figure.dpi"] = 90
plt.xlim(0, 600)
plt.ylim(0, 600)
plt.show()
shap.dependence_plot
seems to return a plot object but you store it no where, right ? If so, that’s probably why you can’t set the limit for the y-axis (since the plot isn’t available yet!). I suggested you to do so :
fig, ax = shap.partial_dependence_plot( # <- storing the plot in ax
"fc", model.predict, X100, ice=False, show=False,
model_expected_value=True, feature_expected_value=True, ylabel="R")
plt.rcParams["figure.dpi"] = 90
ax.set_xlim(0, 600) # <- changed plt by ax
ax.set_ylim(0, 600) # <- changed plt by ax
plt.show()