Plotting¶
plot
¶
Plotting helpers for :class:Spectrogram and :class:RSF outputs.
Thin wrappers around :mod:matplotlib that handle the per-axis
formatting (log-spaced frequency/rate/scale ticks, the upward/downward
rate split, etc.) so notebook code can stay short.
plt_spectrogram
¶
plt_spectrogram(spectrogram: Spectrogram | ndarray, title: str = 'Auditory Spectrogram', figsize: tuple = (12, 6), cmap: str = 'viridis', frmlen_ms: float = 16.0, ax: Optional[Axes] = None, show_colorbar: bool = True, title_fontsize: int = 12, label_fontsize: int = 10, tick_fontsize: int = 9, interpolation: str = 'bilinear') -> Axes
Plot a single auditory spectrogram.
| PARAMETER | DESCRIPTION |
|---|---|
spectrogram
|
Spectrogram dataclass or a raw
TYPE:
|
title
|
Plot title.
TYPE:
|
figsize
|
Figure size. Only used when
TYPE:
|
cmap
|
Matplotlib colormap.
TYPE:
|
frmlen_ms
|
Frame length in ms, used to compute the time axis when a raw array is passed.
TYPE:
|
ax
|
Axes to draw on. If None, a new figure is created and shown.
TYPE:
|
show_colorbar
|
Add a colorbar (only when
TYPE:
|
title_fontsize
|
Title font size.
TYPE:
|
label_fontsize
|
Axis label font size.
TYPE:
|
tick_fontsize
|
Tick label font size.
TYPE:
|
interpolation
|
Interpolation passed to :func:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Axes
|
The axes the spectrogram was drawn on. |
plt_spectrogram_grid
¶
plt_spectrogram_grid(data: List[Dict], n_cols: int = 4, figsize: tuple | None = None, cmap: str = 'viridis', frmlen_ms: float = 16.0, suptitle: str | None = None, save_path: Optional[str] = None) -> None
Plot multiple spectrograms in a grid.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
Each entry must have a
TYPE:
|
n_cols
|
Number of columns in the grid.
TYPE:
|
figsize
|
Figure size. Auto-calculated from
TYPE:
|
cmap
|
Matplotlib colormap.
TYPE:
|
frmlen_ms
|
Frame length in ms, used when raw arrays are passed.
TYPE:
|
suptitle
|
Overall figure title.
TYPE:
|
save_path
|
If given, save the figure to this path at 200 DPI before showing.
TYPE:
|
plt_rsf
¶
plt_rsf(rsf: RSF | ndarray, rates: ndarray | None = None, scales: ndarray | None = None, fold: bool = False, title: str = 'Rate-Scale Representation', figsize: tuple = (10, 8), cmap: str = 'viridis', ax: Optional[Axes] = None, show_colorbar: bool = True, title_fontsize: int = 12, label_fontsize: int = 10, tick_fontsize: int = 9, square: bool = False) -> Axes
Plot a single RSF representation as a 2D scale-by-rate heatmap.
| PARAMETER | DESCRIPTION |
|---|---|
rsf
|
RSF dataclass, or a raw 4D array of shape
TYPE:
|
rates
|
Rate axis values for tick labels. Defaults to
TYPE:
|
scales
|
Scale axis values for tick labels. Defaults to
TYPE:
|
fold
|
If True, average the upward and downward halves and mirror the result back out to produce a symmetric plot.
TYPE:
|
title
|
Plot title.
TYPE:
|
figsize
|
Figure size. Only used when
TYPE:
|
cmap
|
Matplotlib colormap.
TYPE:
|
ax
|
Axes to draw on. If None, a new figure is created and shown.
TYPE:
|
show_colorbar
|
Add a colorbar (only when
TYPE:
|
title_fontsize
|
Title font size.
TYPE:
|
label_fontsize
|
Axis label font size.
TYPE:
|
tick_fontsize
|
Tick label font size.
TYPE:
|
square
|
Force a square aspect ratio on the axes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Axes
|
The axes the RSF was drawn on. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
plt_rsf_grid
¶
plt_rsf_grid(data: List[Dict], rates: ndarray | None = None, scales: ndarray | None = None, fold: bool = False, n_cols: int = 6, figsize: tuple | None = None, cmap: str = 'viridis', suptitle: str | None = None, save_path: Optional[str] = None) -> None
Plot multiple RSF representations in a grid.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
Each entry must have an
TYPE:
|
rates
|
Rate axis values. Defaults to
TYPE:
|
scales
|
Scale axis values. Defaults to
TYPE:
|
fold
|
Forwarded to :func:
TYPE:
|
n_cols
|
Number of columns in the grid.
TYPE:
|
figsize
|
Figure size. Auto-calculated if not given.
TYPE:
|
cmap
|
Matplotlib colormap.
TYPE:
|
suptitle
|
Overall figure title.
TYPE:
|
save_path
|
If given, save the figure to this path at 200 DPI before showing.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If raw RSF arrays are passed but |