def plotpsd(data, dt, ndivide=1, window=hanning, overlap_half=False, ax=None, **kwargs):
"""Plot PSD (Power Spectral Density).
Args:
data (np.ndarray): Input data.
dt (float): Time between each data.
ndivide (int): Do averaging (split data into ndivide, get psd of each, and average them).
overlap_half (bool): Split data to half-overlapped regions.
ax (matplotlib.axes): Axis the figure is plotted on.
kwargs (optional): Plot options passed to ax.plot().
"""
if ax is None:
ax = plt.gca()
vk, psddata = psd(data, dt, ndivide, window, overlap_half)
ax.loglog(vk, psddata, **kwargs)
ax.set_xlabel('Frequency [Hz]', fontsize=20, color='grey')
ax.set_ylabel('PSD', fontsize=20, color='grey')
ax.legend()
评论列表
文章目录