0
点赞
收藏
分享

微信扫一扫

python绘制正弦函数/余弦函数

前言:
numpy的linespace的参数介绍:

start:返回样本数据开始点(这里会用在自变量x)
stop:返回样本数据结束点
num:生成的样本数据量,默认为50
# draw the sinx curve
import  numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-20, 20, 100)
y = np.sin(x)
plt.plot(x, y)
plt.show()
# draw the cos x curve
import  numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-20, 20, 100)
y = np.cos(x)
plt.plot(x, y)
plt.show()

result:
在这里插入图片描述

在这里插入图片描述

举报

相关推荐

0 条评论