Matplotlib是Python中的一個庫,它是數字的-NumPy庫的數學擴展。 Pyplot是Matplotlib模塊的基於狀態的接口,該模塊提供了MATLAB-like接口。
matplotlib.pyplot.acorr()函數:
matplotlib庫的pyplot模塊中的angle_spectrum()函數用於繪製角度光譜。通常,它會計算序列的角度譜並完成繪製。
用法: angle_spectrum(x, Fs=2, Fc=0, window=mlab.window_hanning, pad_to=None, sides=’default’, **kwargs)
參數:此方法接受以下描述的參數:
- x:此參數是數據序列。
- Fs:此參數是標量。默認值為2。
- window:此參數將數據段作為參數,並返回該段的窗口版本。其默認值為window_hanning()
- sides:此參數指定要返回光譜的哪一側。它可以具有以下值:“默認”,“單麵”和“雙麵”。
- pad_to:此參數包含填充數據段的整數值。
- Fc:此參數還包含一個整數值,用於抵消曲線圖的x範圍以反映頻率範圍。其默認值為0
返回值:這將返回以下內容:
- spectrum:這將返回以弧度為單位的角度光譜。
- freqs:這將返回與頻譜中的元素相對應的頻率。
- line:這將返回此函數創建的行。
結果是(spectrum, freqs, line)
以下示例說明了matplotlib.pyplot中的matplotlib.pyplot.angle_spectrum()函數:
範例1:
# Implementation of matplotlib.pyplot.angle_spectrum()
# function
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(10**5)
dt = 0.0001
Fs = 1 / dt
geeks = np.array([24.40, 110.25, 20.05,
22.00, 61.90, 7.80,
15.00, 22.80, 34.90,
57.30])
nse = np.random.randn(len(geeks))
r = np.exp(-geeks / 0.05)
s = 0.1 * np.sin(2 * np.pi * geeks) + nse
# plot angle_spectrum
plt.angle_spectrum(s, Fs = Fs)
# Display the simple spectrum and
# angle_spectrum plot
plt.show()
輸出:
範例2:
# Implementation of matplotlib.pyplot.angle_spectrum()
# function
import matplotlib.pyplot as plt
import numpy as np
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(2 * np.pi * t) + cnse
# plot simple spectrum
plt.subplot(2, 1, 1)
plt.plot(t, s)
# plot angle_spectrum
plt.subplot(2, 1, 2)
plt.angle_spectrum(s, Fs = Fs)
# Display the simple spectrum and
# angle_spectrum plot
plt.show()
輸出:
相關用法
注:本文由純淨天空篩選整理自SHUBHAMSINGH10大神的英文原創作品 matplotlib.pyplot.angle_spectrum() in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。