UserWarning:Matplotlib当前正在使用agg,它是非GUI后端,因此无法显示该图。
UserWarning:Matplotlib当前正在使用agg,它是非GUI后端,因此无法显示该图。
解决方法
答案 0 :(得分:0)
如果要使用plt.show()
,则需要设置其他后端。 Agg
后端只能将绘图写入文件,而不能显示交互式输出。
您可以通过在matplotlibrc文件(https://matplotlib.org/users/customizing.html#the-matplotlibrc-file)中设置backend
字段来全局设置后端。
您还可以在程序中设置后端。只需看看上面链接的页面即可。