Skip to content

map_plot

MATLAB equivalent: sidMapPlot

map_plot

Time-frequency colour map for sidFreqMap results.

map_plot

map_plot(result: FreqMapResult, *, plot_type: str = 'magnitude', frequency_unit: str = 'rad/s', clim: tuple | None = None, ax=None) -> dict

Time-frequency colour map for :func:sid.freq_map results.

This is the Python port of sidMapPlot.m.

Plots the time-varying frequency response (or spectrum / coherence) as a pcolormesh colour map with time on the x-axis and frequency (log scale) on the y-axis.

Parameters:

Name Type Description Default
result FreqMapResult

Result struct returned by :func:sid.freq_map. Must have method == 'freq_map'.

required
plot_type str

What to plot:

  • 'magnitude' -- 20 * log10(|G(w,t)|) in dB (default).
  • 'phase' -- angle(G(w,t)) in degrees.
  • 'noise' -- 10 * log10(noise_spectrum) in dB.
  • 'coherence' -- squared coherence on [0, 1].
  • 'spectrum' -- 10 * log10(noise_spectrum) in dB (alias for time-series data).
'magnitude'
frequency_unit str

'rad/s' (default) or 'Hz'.

'rad/s'
clim tuple of (float, float) or None

Colour axis limits (cmin, cmax). None for automatic scaling (default).

None
ax matplotlib Axes or None

Existing axes to plot into. If None, a new figure is created.

None

Returns:

Type Description
dict

Dictionary with the following keys:

  • 'fig' -- matplotlib Figure handle.
  • 'ax' -- Axes handle.
  • 'mesh' -- QuadMesh handle from pcolormesh.

Raises:

Type Description
SidError

If result is not a FreqMapResult (code: 'invalid_result').

SidError

If plot_type requires a frequency response but the result is time-series only (code: 'no_response').

SidError

If plot_type is 'coherence' but no coherence data is available (code: 'no_coherence').

SidError

If plot_type is unrecognised (code: 'invalid_plot_type').

Examples:

>>> import numpy as np
>>> import sid
>>> N = 4000; u = np.random.randn(N)
>>> y = np.convolve(u, [1, -0.9])[:N] + 0.1 * np.random.randn(N)
>>> result = sid.freq_map(y, u, segment_length=512)
>>> h = sid.map_plot(result, plot_type='magnitude')
Notes

Specification: SPEC.md S6.9 -- Visualization: sidMapPlot

See Also

sid.freq_map : Time-varying frequency response estimation. sid.spectrogram_plot : Spectrogram colour map. sid.bode_plot : Static Bode diagram.

Changelog

2026-04-09 : First version (Python port) by Pedro Lourenco.