python之matplotlib库的简单应用

#画正弦余弦
import matplotlib.pyplot as plt
import numpy as np

x=np.linspace(-2*np.pi,2*np.pi,1000)//既然是画图就得切割多个点

y=np.sin(x)
y1=np.cos(x)

plt.plot(x,y,color="blue",label="sin(x)")//画图规则

plt.plot(x,y1,color="red",label="cos(x)")

plt.legend()
plt.show()
发布了84 篇原创文章 · 获赞 48 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_43900387/article/details/104077394