Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีพล็อต Phase Spectrum ใน Matplotlib ด้วย Python

การพล็อต Phase Spectrum (ซ้ำซ้อนกับ 1004101877)

เนื้อหาบทความนี้เหมือนกับ ID 1004101877 ทั้งหมด ใช้ phase_spectrum() แสดง phase spectrum

ตัวอย่างโค้ด

import matplotlib.pyplot as plt
import numpy as np

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

np.random.seed(0)
dt = 0.01
Fs = 1 / dt
t = np.arange(0, 10, dt)

nse = np.random.randn(len(t))
r = np.exp(-t / 0.05)
cnse = np.convolve(nse, r) * dt
cnse = cnse[:len(t)]
s = 0.1 * np.sin(4 * np.pi * t) + cnse

fig, axs = plt.subplots()
axs.set_title("Phase Spectrum")
axs.phase_spectrum(s, Fs=Fs, color='C2')
plt.show()

หมายเหตุ

บทความนี้ซ้ำกับ ID 1004101877 เนื้อหาและโค้ดเหมือนกันทุกประการ