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]

Spectrogram 1

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...


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}]


enter image description here


enter image description here

  • $\begingroup$ 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... $\endgroup$ – zakk Sep 21 '18 at 22:30
  • $\begingroup$ @zakk See the Details and Options in the docs of Spectrogram (and maybe also SpectrogramArray). $\endgroup$ – corey979 Sep 22 '18 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.