从Audacity 导入 Wav 文件,缩放时间轴,看到 Sine 波形,像示波器一样: 图4 Audacity 查看时域波形 第二、查看频谱图: 菜单上点击 Select -> All,然后 Analyze -> Plot Spectrum,看到频谱图: 图5 Audacity 查看频谱图 图中,频谱的中心频率就是我们设定的 1000 Hz。 至于为何整个频谱像概率分布,
使用plot函数将生成的数据点绘制成图形。 python plt.plot(x, y) 添加标题和坐标轴标签: 为了使图形更具可读性,可以添加标题和坐标轴标签。 python plt.title('Sine Wave') plt.xlabel('x') plt.ylabel('sin(x)') 显示或保存绘制的图形: 最后,使用show函数显示图形,或者使用savefig函数保存图形到文件...
importnumpyasnpimportmatplotlib.pyplotasplt# 原始绘图代码# x = np.linspace(0, 2*np.pi, 100)# y = np.sin(x)# plt.plot(x, y)# 优化后的代码x=np.linspace(0,2*np.pi,100,endpoint=False)# 更加高效y=np.sin(x)plt.plot(x,y,label='Sine Wave',color='blue') 1. 2. 3. 4. 5. ...
importmatplotlib.pyplotasplt# 导入Matplotlib库,用于绘图# 绘制正弦曲线plt.figure(figsize=(10,5))# 设置绘图大小plt.plot(x,y,label='sin(x)',color='blue')# 绘制正弦曲线plt.title('Sine Wave')# 设置标题plt.xlabel('x')# 设置x轴标签plt.ylabel('sin(x)')# 设置y轴标签plt.grid(True)# 显示...
frequency = 1 # 频率 phase = 0 # 相位 # 生成时间序列 t = np.linspace(0, 2*np.pi, 1000) # 计算正弦波形 y = amplitude * np.sin(frequency * t + phase) # 绘制图形 plt.plot(t, y) plt.xlabel('Time') plt.ylabel('Amplitude') plt.title('Sine Wave') plt.grid(True) plt.show(...
# Import IPython's interact function which is used below to # build the interactive widgets from IPython.html.widgets import interact def plot_sine(frequency=4.0, grid_points=12, plot_original=True): """ Plot discrete samples of a sine wave on the interval ``[0, 1]``. """ x = np...
sine_wave = [np.sin(2* np.pi * frequency * x/sampling_rate)forxinrange(num_samples)] 它表示生成0到num_samples范围内的 x,并且对于每个x值,生成一个值为该值的值。你可以将此值视为y轴值。然后将所有这些值放入列表中。十分简单。 nframes=num_samples ...
Learn how to plot FFT of sine wave and cosine wave using Python. Understand FFTshift. Plot one-sided, double-sided and normalized spectrum using FFT
set_title("sine wave") ax.set_xlabel('angle') ax.set_ylabel('sine') 调用axes 对象的 plot() 方法,对 x 、 y 数组进行绘图操作: ax.plot(x,y) Matplotlib axes类使用详解 Matplotlib 定义了一个 axes 类(轴域类),该类的对象被称为 axes 对象(即轴域对象),它指定了一个有数值范围限制的绘图...
fig,axs=plt.subplots(1,3,figsize=(15,5))# 创建一个1行3列的网格fori,axinenumerate(axs):x=np.linspace(0,2*np.pi,100)y=np.sin(x*(i+1))# 改变频率以区分图像ax.plot(x,y)ax.set_title(f'Sine Wave{i+1}')ax.set_xlabel('X axis')ax.set_ylabel('Y axis')plt.tight_layout()#...