03 Draw a curve
x = range(-100, 100)
y = [i**2 for i in x]
#绘制一元二次方程曲线
plt.plot(x, y)
plt.savefig('result.jpg') # plt.savefig('cos')自动生成cos.png
plt.show()
Plotting sine and cosine curves
Generate x coordinates (100 equivalence series from 0-10)
x = np.linspace(0, 10, 100)
#绘制正弦曲线
sin_y = np.sin(x)
plt.plot(x, sin_y)
#绘制余弦曲线
cos_y = np.cos(x)
plt.plot(x, cos_y)
#存储图表为.jpg格式,默认为.png格式
plt.savefig('sin_cos,jpg')
plt.show()