plots the spectrogram of list.


uses partitions of length n.


uses partitions with offset d.


applies a smoothing window wfun to each partition.


pads partitions with zeros to length m prior to the computation of the transform.


plots the spectrogram of audio.

Details and Options

  • Spectrogram[list] plots the magnitude of the short-time Fourier transform (STFT), computed as discrete Fourier transform (DFT) of partitions of list.
  • Compute the short-time Fourier transform of list using ShortTimeFourier.
  • Spectrogram[list] uses partitions of length and offset , where m is Length[list].
  • The partition length n and offset d can be expressed as an integer number (interpreted as number of samples) or as time or sample quantities.
  • If necessary, fixed padding is used on the right to make all the partitions the same size.
  • Spectrogram displays only the first half of the magnitude of the discrete Fourier transform due to the symmetry property of the transform.
  • In Spectrogram[list,n,d,wfun], the smoothing window wfun can be specified using a window function that will be sampled between and or a list of length n. The default window is DirichletWindow, which effectively does no smoothing.
  • Spectrogram works with numeric lists as well as Audio and Sound objects.
  • For multichannel sound objects, the spectrogram is computed over the sum of all channels.
  • Spectrogram accepts all ArrayPlot options with the following additions and changes:
  • AspectRatio1/3ratio of height to width
    ColorFunctionAutomatichow each cell should be colored
    FrameTicksAutomaticwhat ticks to include on the frame
    MaxPlotPointsAutomaticthe maximum number of points to include
    MethodAutomaticmethod used for frequency binning
    PlotRangeAutomaticthe range of values to plot
    SampleRateAutomaticsampling rate assumed for the input list
  • Possible settings for Method include:
  • Automaticautomatic choice of binning
    "LinearFrequency"no binning
    "MelFrequency"binning according to the mel scale
  • Use Method->{"MelFrequency",n,fmin,fmax} to specify the number of bins n as well as the minimum and maximum frequencies.
  • Specific settings for PlotRange can be used to control the maximum frequency:
  • "Music"{0,10000}common frequency range for music
    "Speech"{0,5000}common frequency range for speech
  • For the setting SampleRate->r and a list of length m, time is ranged from to , and the frequencies are in the range to .


open allclose all

Basic Examples  (2)

Spectrogram of a chirp signal:

Spectrogram of an audio signal:

Scope  (1)

Use a specific window size and offset:

By default, a suitable window size and offset is chosen:

Use smaller window size to reduce the frequency resolution:

Use larger window size to improve the frequency resolution:

Specify the smoothing window function:

No smoothing:

Options  (8)

AspectRatio  (1)

By default, an aspect ratio of is used:

Change the aspect ratio of the spectrogram:

ColorFunction  (1)

Use a built-in color gradient as the color function:

Use an arbitrary color function:

PlotRange  (4)

PlotRange->Automatic automatically computes the frequency range to display:

This is equivalent to PlotRange->{All,Automatic,All}:

Show the full spectrogram:

Zoom into a specific part of the spectrogram:

Use PlotRange->{min,max} to control the frequency range of the spectrogram:

Specify range of frequencies:

Specify maximum frequency:

Method  (1)

By default, frequency is shown using linear scaling:

Use mel frequency scaling:

SampleRate  (1)

Specify the sampling rate of the data:

Applications  (3)

Spectrogram of a sound signal:

Spectrogram of an impulsive sound:

Spectrogram of an image:

Properties & Relations  (1)

Create a spectrogram from the SpectrogramArray:

Comparison with the default Spectrogram output:

Neat Examples  (1)

Sound and spectrogram of dual-tone for Wolfram Research customer service number:

Wolfram Research (2012), Spectrogram, Wolfram Language function, https://reference.wolfram.com/language/ref/Spectrogram.html (updated 2017).


Wolfram Research (2012), Spectrogram, Wolfram Language function, https://reference.wolfram.com/language/ref/Spectrogram.html (updated 2017).


@misc{reference.wolfram_2021_spectrogram, author="Wolfram Research", title="{Spectrogram}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/Spectrogram.html}", note=[Accessed: 17-June-2021 ]}


@online{reference.wolfram_2021_spectrogram, organization={Wolfram Research}, title={Spectrogram}, year={2017}, url={https://reference.wolfram.com/language/ref/Spectrogram.html}, note=[Accessed: 17-June-2021 ]}


Wolfram Language. 2012. "Spectrogram." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/Spectrogram.html.


Wolfram Language. (2012). Spectrogram. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Spectrogram.html