Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Visualizations

Authors
Affiliations
The Eric and Wendy Schmidt Center for Data Science & Environment
University of California, Berkeley
The Eric and Wendy Schmidt Center for Data Science & Environment
University of California, Berkeley
The Eric and Wendy Schmidt Center for Data Science & Environment
University of California, Berkeley

JupyterBioacoustic supports custom visualization functions alongside the built-in spectrograms. Several are included in jupyter_bioacoustic.utils.visualizations and can be referenced by name. Custom functions can also be passed directly as callables.

Each function takes (mono, sr, width) and returns a dict with either a matrix (2D array — rendered automatically) or png_bytes (full control).

Author: Brookie Guzder-Williams (bguzder-williams@berkeley.edu)
Affiliation: The Eric and Wendy Schmidt Center for Data Science & Environment
[JBA] Debug mode enabled. Logs → /Users/brookie/code/dse/jupyter_bioacoustic/repos/jupyter_bioacoustic/demo/jba_debug.log

1. Built-in Visualizations by Name

The visualizations module includes several ready-to-use functions that can be referenced by string name: 'spectrogram' (or 'plain'), 'mel', 'log_frequency', 'bandpass', 'waveform'.

Loading...
Loading...

2. Standalone Usage

The visualization functions can be used outside the widget — for analysis, figures, or custom pipelines. The vis.plot() helper renders any visualization dict as a matplotlib figure.

Note: the first time you run this code an audio-file will be downloaded

Downloading Sample Audio: this may take a moment...
- audio saved (audio/test_auido.flac)
matrix shape: (256, 1995)
freq_min: 50.0 freq_max: 24000.0
freq_scale: log
matrix min: 0.0 max: 100.40672495176402
<Figure size 1200x400 with 1 Axes>

3. Custom Visualization Function (PNG return)

For complete control over the rendering — custom colormaps, dynamic range, etc. — use vis.render_png() which handles dB normalization and colormap rendering. For even more control (custom layouts, overlays, multi-panel), render with matplotlib directly and return png_bytes.

Loading...
Loading...

4. Birdsong Bandpass (custom rendering + bandpass)

A bandpass spectrogram focused on 1–8 kHz (typical birdsong range) with the viridis colormap and tighter dynamic range for contrast enhancement. Demonstrates PNG return with a focused frequency window.

Loading...
Loading...