使用python进行绘图是其重要功能之一,本文讲解使用python进行正弦余弦波及其复合波形的绘制方法。
程序
import numpy as np
import matplotlib.pyplot as plt
t=np.arange(-10,10,0.1)
y=np.sin(t)
plt.title("y=sin(t) waveform")
plt.plot(t,y)
plt.show()
程序:
import numpy as np
import matplotlib.pyplot as plt
t=np.arange(-10,10,0.1)
y=np.cos(t)
plt.title("y=cos(t) waveform")
plt.plot(t,y)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
t=np.arange(-10,10,0.1)
y=2*np.sin(t)-0.7*np.cos(t)+np.sin(t)*np.sin(t)*np.cos(t)-1
plt.title("y=2*sin(t)-0.7*cos(t)+sin(t)*sin(t)*cos(t)-1 waveform")
plt.plot(t,y)
plt.show()