How to change size of plot in xgboost.plot_importance?

15,533

It looks like plot_importance return an Axes object

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

It also looks like you can pass an axes in

fig, ax = plt.subplots(figsize=(h, w))
xgboost.plot_importance(..., ax=ax)
Share:
15,533
dsl1990
Author by

dsl1990

Updated on June 12, 2022

Comments

  • dsl1990
    dsl1990 almost 2 years
    xgboost.plot_importance(model, importance_type='gain')
    

    I am not able to change size of this plot. I want to save this figure with proper size so that I can use it in pdf. I want similar like figize

  • Max Power
    Max Power over 6 years
    ^ only the second option works for me as well. Regardless, thanks for the answer!
  • tbrodbeck
    tbrodbeck almost 3 years
    it is first width and then height btw :)