no display name and no $DISPLAY environment variable ============================ @Neil's answer is one (perfectly valid!) way of doing it, but you can also simply call matplotlib.use('Agg') before importing matplotlib.pyplot, and then continue as no
正弦图像: #coding:utf-8import numpy as npimport matplotlib.pyplot as pltx=np.linspace(0,10,1000)y=np.sin(x)z=np.cos(x**2)#控制图形的长和宽单位为英寸,# 调用figure创建一个绘图对象,并且使它成为当前的绘图对象.plt.figure(figsize=(8,4))#$可以让字体变得跟好看#给所绘制的曲线一个名字,此名字在图示(legend)中显示.# 只要在字符串前后添加"$&qu