I am trying to use plt.specgram
But I found something weird in the x-axis setting.
My data is as below..
Date Value
2018-01-01 0.1
2018-01-02 0.4
...
2020-02-27 0.7
2020-02-28 0.3
The length of data is 821. (The dates I wrote are temporary values)
When I plot the spectrogram as below:
Pxx, freqs, bins, im=ax.specgram(df, NFFT=256, Fs=1.0, noverlap=220, cmap='inferno', mode='psd')
mesh=ax.pcolormesh(bins, freqs, Pxx, norm=LogNorm(), cmap='inferno')
the x-axis only shows values below 700.
When I set
noverlap = 75, the x-axis shows values over 700.When I set
nfft = 256, the x-axis shows values up to about 220.When I set
nfft = 256*3, the x-axis becomes up to about 256*2.
If I want to the x-axis to show values up to 821, how do I set the parameters of specgram?
(I want to set nfft = 256, and noverlap = 220)
This is the fig1
This is the fig2
This is the fig3



noverlap? Padding? – OverLordGoldDragon Nov 17 '22 at 15:52hop_size=1, while indeed very redundant and generally undesired, has its uses, and is certainly worth mentioning, especially with highly time-localized windows. In yet other cases we have no choice, e.g. one-integral inversion. – OverLordGoldDragon Nov 17 '22 at 18:09scipyandlibrosa. Also "just FFT on 768 data samples" is true only with a flat window, though here we're close. – OverLordGoldDragon Nov 17 '22 at 23:04