Wrong Axis Title and Ticks #26
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Maximum Frequency Value After Performing The STFT Appears as 0.5 Instead of 512 Hz
Some STFT implementations (like those in libraries such as SciPy) normalize the frequency axis to a range of

[0,0.5], which represents the fraction of the Nyquist frequency relative to the sampling rate.Solution
fs) in thestftcall. Ensurefsis provided correctly.The short explanation is that SciPy’s STFT defaults to a normalized frequency range of $[0, 0.5]$ (cycles per sample) if you don’t provide a sampling rate (
fs). This is why you see a maximum frequency of0.5instead of512 Hz.To fix this, pass your actual sampling frequency (e.g.,
fs=1024) when callingstft. That way, SciPy will correctly scale the frequency axis up to the Nyquist limit (fs/2 = 512 Hzin your case).In summary:
fsprovided → Frequencies shown in cycles per sample (max = 0.5).fs=1024provided → Frequencies shown in Hz (max = 512 Hz).That’s it! Specifying
fsin the STFT call ensures your frequency axis matches real-world units, and you’ll see the maximum frequency you expect.