Linux下plt.savefig出错

在Linux服务器上运行程序时,不免需要绘图,如果单单使用 

import matplotlib.pyplot as plt

会出现以下错误

为此需要在程序中先进行如下设置

import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pylot as plt
plt.plot([1,2],[3,4])
plt.savefig('test.png')

这样就可以正常保存图片了。

Ctrl + C 强制退出Linux程序

猜你喜欢

转载自blog.csdn.net/qq_38826019/article/details/84324291
plt