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

How to change size of plot in xgboost.plot_importance?

xgboost.plot_importance(model, importance_type='gain')

我无法更改此图的大小。我想以适当的大小保存此图,以便我可以在 pdf 中使用它。我想要类似 figize

看起来像plot_importancereturn an Axes object

ax = xgboost.plot_importance(...)
fig = ax.figure
fig.set_size_inches(h, w)

看起来你也可以在

中传递一个轴
fig, ax = plt.subplots(figsize=(h, w))
xgboost.plot_importance(..., ax=ax)