1 import matplotlib.pyplot as plt 2 import numpy as np 3 #生成0-10之间100个等差数 4 x = np.linspace(0,10,100) 5 sin_y = np.sin(x) 6 plt.plot(x,sin_y) 7 cos_y = np.cos(x) 8 plt.plot(x,cos_y) 9 #保存成图片 10 plt.savefig('sin_cos.jpg') 11 plt.show()