python绘制正弦函数/余弦函数
前言:numpy的linespace的参数介绍:start:返回样本数据开始点(这里会用在自变量x)stop:返回样本数据结束点num:生成的样本数据量,默认为50# draw the sinx curveimportnumpy as npimport matplotlib.pyplot as pltx = np.linspace(-20, 20, 100)y = np.sin(x)plt.plo
·
前言:
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)