如何在xgboost.plot_importance中更改绘图的大小?

dsl*_*990 7 python machine-learning matplotlib python-3.x xgboost

xgboost.plot_importance(model, importance_type='gain')
Run Code Online (Sandbox Code Playgroud)

我无法改变这个情节的大小.我想以适当的大小保存这个数字,以便我可以在pdf中使用它.我想要类似的figize

tac*_*ell 25

看起来像是plot_importance 返回一个Axes对象

ax = xgboost.plot_importance(...)
fig = ax.figure
fig.set_size_inches(h, w)
Run Code Online (Sandbox Code Playgroud)

看起来你也可以通过轴

fig, ax = plt.subplots(figsize=(h, w))
xgboost.plot_importance(..., ax=ax)
Run Code Online (Sandbox Code Playgroud)

  • 对我来说,只有最后一个变种似乎有效.谢谢 (2认同)
  • ^ 只有第二个选项也适合我。不管怎样,谢谢您的回答! (2认同)