sdr.plot.spectrogram(x: ArrayLike, sample_rate: float = 1.0, window: str | ArrayLike = 'hann', length: int | None = None, overlap: int | None = None, fft: int | None = None, x_axis: 'one-sided' | 'two-sided' = 'two-sided', **kwargs)

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

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

Parameters:
x: ArrayLike

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

sample_rate: float = 1.0

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

window: str | ArrayLike = 'hann'

The windowing function to use. This can be a string or a vector of length length.

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.

x_axis: 'one-sided' | 'two-sided' = 'two-sided'

The x-axis scaling. Options are to display a one-sided spectrum or two-sided spectrum.

**kwargs

Additional keyword arguments to pass to matplotlib.pyplot.pcolormesh().

Notes

By default, the color bar range is from the 10th to 100th percentile. This is to provide more dynamic range in the “active” values, and not the noise. This can be changed by passing vmin and vmax as keyword arguments.