# Two-tone spectrogram

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:

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?

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


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:

f/@{
ColorData[{"RedBlueTones","Reverse"}],ColorData[{"CandyColors","Reverse"}],
"ThermometerColors",ColorData[{"BrownCyanTones","Reverse"}],
"Rainbow","DarkRainbow",
"TemperatureMap","LightTemperatureMap",
(Blend[{Blue,Red},#]&),(Blend[{Cyan,Pink},#]&),
(Blend[{Darker@Blue,Lighter@Red},#]&),(Blend[{Lighter@Blue,Darker@Red},#]&)}


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