# Spectrogram of low-frequency data

I generate the following data

data = Table[Sin[2 π*100*t] + Sin[2 π*140*t], {t, 0, 10, 1/1023}];


and the spectrogram, as expected, shows two horizontal lines corresponding to the two frequencies:

Spectrogram[data, SampleRate -> 1023]


Now, if I try to do the same with data at lower frequencies, such as:

data2 = Table[Sin[2 π*2*t] + Sin[2 π*6*t], {t, 0, 10, 1/1023}];


the spectrogram does not show the two frequencies, not even if I try changing the PlotRange.

What am I doing wrong? I have tried modifying the sampling rate, or changing the grouping in the Spectrogram function, but it does not seem to help...

## 1 Answer

You have a range from 0 to 511.5, so the frequencies at 2 & 6 are simply not visible. PlotRange itself doesn't help because you need to increase also the resolution:

Spectrogram[data2, 1024, SampleRate -> 1023, PlotRange -> {All, {0, 10}}, FrameTicks -> {{{2, 2}, {6, 6}}, Automatic}]


v10.4:

v11.3:

• Thanks! However I will accepted your answer, but I have a question: 1024 should be the number of partitions... How does it increase the resolution? Also, how could I get some sharp lines, rather than 1-pixel-wide lines? I can of course change the sampling rate of the data... – zakk Sep 21 '18 at 22:30
• @zakk See the Details and Options in the docs of Spectrogram (and maybe also SpectrogramArray). – corey979 Sep 22 '18 at 20:47