【问题标题】:UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figureUserWarning: Matplotlib 目前正在使用 agg,这是一个非 GUI 后端,所以无法显示图
【发布时间】:2020-01-08 00:14:40
【问题描述】:
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.

如何解决

【问题讨论】:

  • 您能否提供有关您正在尝试执行的操作的更多详细信息,也许是您正在使用的代码的 sn-p 以及错误的完整堆栈跟踪?仅使用错误文本很难获得确切的解决方案。如果您使用的是 jupyter 笔记本,请查看 this

标签: python matplotlib


【解决方案1】:

如果你想使用plt.show(),你需要设置一个不同的后端。 Agg 后端只能将绘图写入文件,不能显示交互式输出。 您可以通过在 matplotlibrc 文件 (https://matplotlib.org/users/customizing.html#the-matplotlibrc-file) 中设置 backend 字段来全局设置后端。

您还可以在程序中设置后端。看看上面链接的页面。

【讨论】:

    猜你喜欢
    • 2020-06-28
    • 2019-08-21
    • 1970-01-01
    • 2022-11-10
    • 2022-12-01
    • 2019-11-01
    • 2019-06-16
    • 2019-07-02
    • 2020-04-30
    相关资源
    最近更新 更多