【问题标题】:Cannot save decision tree plot using Matplotlib无法使用 Matplotlib 保存决策树图
【发布时间】:2021-05-04 15:52:38
【问题描述】:

字体太小无法显示,所以我希望保存图像并在本地而不是在 Jupyter 上查看。

fig, axes = plt.subplots(nrows = 1,ncols = 1,figsize = (4,4), dpi=300)
tree.plot_tree(clf,filled=True,rounded=True)
plt.savefig('foo.png')

但是,保存的图像是完全空白的。

我该如何解决这个问题?

【问题讨论】:

    标签: python matplotlib scikit-learn


    【解决方案1】:

    尝试在斧头上绘图:

    fig, axes = plt.subplots(nrows = 1,ncols = 1,figsize = (4,4), dpi=300)
    tree.plot_tree(clf,filled=True,rounded=True, ax=axes)
    plt.savefig('foo.png')
    

    【讨论】:

      猜你喜欢
      • 2019-06-12
      • 1970-01-01
      • 2016-11-15
      • 2021-04-10
      • 2013-07-26
      • 2014-11-26
      • 2013-05-01
      • 2011-06-26
      • 2023-03-12
      相关资源
      最近更新 更多