The default spectrogram command uses a single color and appears to just vary the saturation of the color to express intensity. So, for example, in the default implementation which looks like this:

enter image description here

its sort of a yellow which is darkened or lightened according to intensity.

I would rather have a bi-tone graphic in which there are two colors, say red and blue, and the intensity is continuous scale going from dark blue (low) to dark red (high). How can I do this?

  • $\begingroup$ Use the option ColorFunction -> (Blend[{Blue, Red}, #] &)? $\endgroup$ – kglr Nov 2 '17 at 14:59
  • $\begingroup$ or do e.g. Spectrogram[ExampleData[{"Sound", "Apollo13Problem"}], ColorFunction -> "ThermometerColors"] $\endgroup$ – J. M. will be back soon Nov 2 '17 at 15:14
  • $\begingroup$ Right, ThermometerColors is the right idea. $\endgroup$ – Tyler Durden Nov 2 '17 at 15:47

You can play with custom interactive selection (see definition of f below):

Manipulate[f[(Blend[{c1, c2}, #] &)], {c1, Blue}, {c2, Red}]

enter image description here

Generally, selecting a color scheme is an artsy process, dependent on how you data vary along the color gradient. Check out ColorSchemes for builtin variety. You can also reverse them as for example "RedBlueTones" is inverse of your scale but you can use

ColorData[{"RedBlueTones", "Reverse"}]

Let's compare. Define a test function:

f[c_] := Spectrogram[ExampleData[{"Audio", "DogBark"}], ColorFunction -> c]

Apply to some cases:


enter image description here


Following on J.M.'s comment, the solution is to use a ColorFunction, Spectrogram[ExampleData[{"Sound", "Apollo13Problem"}], ColorFunction -> "LightTemperatureMap"]

enter image description here


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.