xgboost plot importance figure size

Georg Heiler picture Georg Heiler · Oct 17, 2016 · Viewed 8.3k times · Source

How can I change the figure size of xgboost's plot importance function?

Trying to pass a figsize=(10,20) fails with the exception of unknown attribute.

Answer

AJ Cloete picture AJ Cloete · Jan 18, 2017

You can pass an axis in the ax argument in plot_importance(). For instance, use this wrapper:

def my_plot_importance(booster, figsize, **kwargs): 
    from matplotlib import pyplot as plt
    from xgboost import plot_importance
    fig, ax = plt.subplots(1,1,figsize=figsize)
    return plot_importance(booster=booster, ax=ax, **kwargs)

Then use my_plot_importance() instead of plot_importance()