简单的画图程序:
#!/usr/bin/python #encoding:utf-8 import matplotlib.pyplot as plt import numpy as np X=np.linspace(-np.pi,np.pi,256,endpoint=True)#-π to+π的256个值 C,S=np.cos(X),np.sin(X) plt.plot(X,C) plt.plot(X,S) plt.show() plt.savefig(r"/home/zhoujianwei/zjw/save_test.png",dpi=520)
解决办法:
在import matplotlib.pyplot as plt前添加:
import matplotlib as mpl mpl.use('Agg')