【问题标题】:How to change size of plot in xgboost.plot_importance?如何更改 xgboost.plot_importance 中的绘图大小?
【发布时间】:2017-04-01 13:52:45
【问题描述】:
xgboost.plot_importance(model, importance_type='gain')

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

【问题讨论】:

    标签: python python-3.x matplotlib machine-learning xgboost


    【解决方案1】:

    看起来像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)
    

    【讨论】:

    • ^ 只有第二个选项也适用于我。无论如何,感谢您的回答!
    • 它是第一个宽度,然后是高度 btw :)
    猜你喜欢
    • 2021-11-24
    • 1970-01-01
    • 1970-01-01
    • 2021-04-17
    • 2022-01-19
    • 2018-05-13
    • 2021-02-26
    • 2020-02-17
    • 1970-01-01
    相关资源
    最近更新 更多