前言:
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: