3
$\begingroup$

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.

enter image description here 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?

$\endgroup$
3
  • $\begingroup$ 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. . $\endgroup$ Commented Mar 18, 2015 at 22:46
  • $\begingroup$ @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. $\endgroup$
    – balboa
    Commented Mar 18, 2015 at 23:15
  • $\begingroup$ The second plot looks like a bug indeed. The tooltip indicates the 3000 line as being 5000. $\endgroup$ Commented Mar 18, 2015 at 23:24

1 Answer 1

1
$\begingroup$

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}},
  PlotRangePadding -> {.1, 500},
  FrameTicks -> {yTicks, Automatic}]

plot

$\endgroup$
1
  • $\begingroup$ Thank you for the solution. I'm thinking should I report the bug... $\endgroup$
    – balboa
    Commented Mar 19, 2015 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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