【问题标题】:Why does Matplotlib saved figure look weird? [duplicate]为什么 Matplotlib 保存的图看起来很奇怪? [复制]
【发布时间】:2021-11-12 22:02:44
【问题描述】:

我正在使用绘图 pandas 数据框,并使用以下代码保存了结果图。输出文件在图像查看器中打开时看起来很奇怪,如下所示。我不明白为什么背景不是全白的。

我使用的是名为 Zorin 的 Linux 操作系统,它是 Ubuntu 的衍生产品。

    fig, ax = plt.subplots(figsize=(15, 10))
    account_profit_df.plot(
        style="*-",
        figsize=(15, 10),
        title="test",
        ax=ax,
    )
    plt.grid()
    fig.savefig(
        
        image_path_backtest,
        bbox_inches="tight",
        
    )

【问题讨论】:

    标签: python-3.x pandas matplotlib


    【解决方案1】:

    这是默认行为,您可以使用以下命令设置背景颜色:fig.patch.set_facecolor('white')

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多