sdr.plot.spectrogram(x: ArrayLike, sample_rate: float | None = None, window: str | float | tuple | None = 'hann', length: int | None = None, overlap: int | None = None, fft: int | None = None, detrend: 'constant' | 'linear' | False = False, ax: Axes | None = None, y_axis: 'auto' | 'one-sided' | 'two-sided' = 'auto', **kwargs)

Plots the spectrogram of a time-domain signal \(x[n]\) using Welch’s method.

Note

This function uses scipy.signal.spectrogram() to estimate the spectrogram of the time-domain signal.

Parameters:
x: ArrayLike

The time-domain signal \(x[n]\).

sample_rate: float | None = None

The sample rate \(f_s\) of the signal in samples/s. If None, the x-axis will be label as “Samples” and the y-axis as “Normalized frequency”.

window: str | float | tuple | None = 'hann'

The SciPy window definition. See scipy.signal.windows.get_window() for details. If None, no window is applied.

length: int | None = None

The length of each segment in samples. If None, the length is set to 256.

overlap: int | None = None

The number of samples to overlap between segments. If None, the overlap is set to length // 2.

fft: int | None = None

The number of points to use in the FFT. If None, the FFT length is set to length.

detrend: 'constant' | 'linear' | False = False

The type of detrending to apply. Options are to remove the mean or a linear trend from each segment.

ax: Axes | None = None

The axis to plot on. If None, the current axis is used.

y_axis: 'auto' | 'one-sided' | 'two-sided' = 'auto'

The y-axis scaling. Options are to display a one-sided spectrum or a two-sided spectrum. The default is "auto" which selects "one-sided" for real-valued signals and "two-sided" for complex-valued signals.

**kwargs

Additional keyword arguments to pass to matplotlib.pyplot.pcolormesh(). The following keyword arguments are set by default. The defaults may be overwritten.

  • "vmin": 10th percentile

  • "vmax": 100th percentile

  • "shading": "gouraud"