17
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

dsl1990
  • 1,157
  • 5
  • 13
  • 25

2 Answers2

49

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)
tacaswell
  • 84,579
  • 22
  • 210
  • 199
1
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(10, 20))
xgb.plot_importance(bst, ax=ax)
plt.show()
yanachen
  • 3,401
  • 8
  • 32
  • 64