# Ticks not positioned correctly on spectrogram

For some reason if I set manually ticks on spectrogram, they are not drawn correctly. If you check on the first graph below it is in descending order from top to bottom (8000, 6000, 4000, ...), while on second graph where I set ticks manually it is in ascending order (this gives wrong values of frequencies). Reversing the ticks list does not solve the issue.

What I think that happens is that frame is showing ticks relative to top, while spectrogram frequencies are drawn relative to bottom. Any ideas on how to solve this?

• I cannot reproduce this (win8.1/V10.0.2). My result. Frameticks at 4000 and 6000 (not 5000 as above). If you look closely, your "5000" is probably 6000 with part of the 6 cut off which makes it look like a 5. Perhaps you should increase magnification or so. . Commented Mar 18, 2015 at 22:46
• @SjoerdC.deVries You are totally right, that was a typo. I just edited the question. The problem is that in original spectrogram tick are like 8000, 6000, 4000, 2000 (from top to bottom), and when I set them manually they become like 3000, 4000, 5000 (instead of 5000, 4000, 3000). This leads to incorrectly shown frequencies in second plot. Commented Mar 18, 2015 at 23:15
• The second plot looks like a bug indeed. The tooltip indicates the 3000 line as being 5000. Commented Mar 18, 2015 at 23:24

It seems to me you have found a bug. The following is a work-around you might use to get the labeling you want.

The trick depends on the y-axis labels you want being related to the labels you are getting by a simple linear function.

yTicks = {#, 8000 - #} & /@ (1000 Range[2, 5])

{{2000, 6000}, {3000, 5000}, {4000, 4000}, {5000, 3000}}

sound =
Play[Sin[2 π 5000 t] + Sin[2 π 4000 t], {t, 0, 4}, SampleRate -> 16000];
Spectrogram[sound,
PlotRange -> {All, {3000, 6000}},