biosppy.plotting

biosppy.plotting

This module provides utilities to plot data.

copyright:
  1. 2015-2026 by Instituto de Telecomunicacoes

license:

BSD 3-clause, see LICENSE for more details.

Functions

add_logo(fig)

color_palette(idx)

Color palette to use throughout the biosppy package

plot_abp([ts, raw, filtered, onsets, ...])

Create a summary plot from the output of signals.abp.abp.

plot_acc([ts, raw, vm, sm, units, path, show])

Create a summary plot from the output of signals.acc.acc.

plot_bcg([ts, raw, filtered, jpeaks, ...])

Create a summary plot from the output of signals.bcg.bcg.

plot_biometrics([assessment, eer_idx, path, ...])

Create a summary plot of a biometrics test run.

plot_bvp([ts, raw, filtered, onsets, ...])

Create a summary plot from the output of signals.bvp.bvp.

plot_clustering([data, clusters, path, show])

Create a summary plot of a data clustering.

plot_ecg([ts, raw, filtered, rpeaks, ...])

Create a summary plot from the output of signals.ecg.ecg.

plot_eda([ts, raw, filtered, edr, edl, ...])

Create a summary plot from the output of signals.eda.eda.

plot_eeg([ts, raw, filtered, labels, ...])

Create a summary plot from the output of signals.eeg.eeg.

plot_egm([ts, raw, filtered, rhythm, ...])

Create a summary plot from the output of signals.egm.egm.

plot_emg([ts, sampling_rate, raw, filtered, ...])

Create a summary plot from the output of signals.emg.emg.

plot_filter([ftype, band, order, frequency, ...])

Plot the frequency response of the filter specified with the given parameters.

plot_hrv(rri[, rri_trend, td_out, nl_out, ...])

Create a summary plot of a HRV analysis.

plot_hrv_fbands([frequencies, powers, ...])

Plots the power spectrum and highlights the defined frequency bands from the output of signals.hrv.compute_fbands.

plot_hrv_hist([rri, bins, q_hist, hti, ...])

Plots the RRI histogram with the corresponding geometrical HRV features from the output of signals.hrv.compute_geometrical.

plot_pcg([ts, raw, filtered, peaks, ...])

Create a summary plot from the output of signals.pcg.pcg.

plot_poincare([rri, s, sd1, sd2, legends, ...])

Plot a Poincaré plot of a series of RR intervals (RRI[i+1] vs.

plot_ppg([ts, raw, filtered, peaks, ...])

Create a summary plot from the output of signals.ppg.ppg.

plot_resp([ts, raw, filtered, zeros, ...])

Create a summary plot from the output of signals.ppg.ppg.

plot_rri(rri[, rri_trend, legends, ax, show])

Plot a series of RR intervals.

plot_spectrum([signal, sampling_rate, path, ...])

Plot the power spectrum of a signal (one-sided).

biosppy.plotting.color_palette(idx)[source]

Color palette to use throughout the biosppy package

Parameters:

idx (str or int) – identifier of color to use

Returns:

color_id (str) – hexadecimal color code chosen

biosppy.plotting.plot_abp(ts=None, raw=None, filtered=None, onsets=None, heart_rate_ts=None, heart_rate=None, path=None, show=False)[source]

Create a summary plot from the output of signals.abp.abp.

Parameters:
  • ts (array) – Signal time axis reference (seconds).

  • raw (array) – Raw ABP signal.

  • filtered (array) – Filtered ABP signal.

  • onsets (array) – Indices of ABP pulse onsets.

  • heart_rate_ts (array) – Heart rate time axis reference (seconds).

  • heart_rate (array) – Instantaneous heart rate (bpm).

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_acc(ts=None, raw=None, vm=None, sm=None, units=None, path=None, show=False)[source]

Create a summary plot from the output of signals.acc.acc.

Parameters:
  • ts (array) – Signal time axis reference (seconds).

  • raw (array) – Raw ACC signal.

  • vm (array) – Vector Magnitude feature of the signal.

  • sm (array) – Signal Magnitude feature of the signal

  • units (str, optional) – Units of the vertical axis. If provided, the plot title will include the units information. Default is None.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_bcg(ts=None, raw=None, filtered=None, jpeaks=None, templates_ts=None, templates=None, heart_rate_ts=None, heart_rate=None, path=None, show=False)[source]

Create a summary plot from the output of signals.bcg.bcg.

Parameters:
  • ts (array) – Signal time axis reference (seconds).

  • raw (array) – Raw ECG signal.

  • filtered (array) – Filtered ECG signal.

  • ipeaks (array) – I-peak location indices.

  • templates_ts (array) – Templates time axis reference (seconds).

  • templates (array) – Extracted heartbeat templates.

  • heart_rate_ts (array) – Heart rate time axis reference (seconds).

  • heart_rate (array) – Instantaneous heart rate (bpm).

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_biometrics(assessment=None, eer_idx=None, path=None, show=False)[source]

Create a summary plot of a biometrics test run.

Parameters:
  • assessment (dict) – Classification assessment results.

  • eer_idx (int, optional) – Classifier reference index for the Equal Error Rate.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_bvp(ts=None, raw=None, filtered=None, onsets=None, heart_rate_ts=None, heart_rate=None, path=None, show=False)[source]

Create a summary plot from the output of signals.bvp.bvp.

Parameters:
  • ts (array) – Signal time axis reference (seconds).

  • raw (array) – Raw BVP signal.

  • filtered (array) – Filtered BVP signal.

  • onsets (array) – Indices of BVP pulse onsets.

  • heart_rate_ts (array) – Heart rate time axis reference (seconds).

  • heart_rate (array) – Instantaneous heart rate (bpm).

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_clustering(data=None, clusters=None, path=None, show=False)[source]

Create a summary plot of a data clustering.

Parameters:
  • data (array) – An m by n array of m data samples in an n-dimensional space.

  • clusters (dict) – Dictionary with the sample indices (rows from data) for each cluster.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_ecg(ts=None, raw=None, filtered=None, rpeaks=None, templates_ts=None, templates=None, heart_rate_ts=None, heart_rate=None, units=None, path=None, show=False)[source]

Create a summary plot from the output of signals.ecg.ecg.

Parameters:
  • ts (array) – Signal time axis reference (seconds).

  • raw (array) – Raw ECG signal.

  • filtered (array) – Filtered ECG signal.

  • rpeaks (array) – R-peak location indices.

  • templates_ts (array) – Templates time axis reference (seconds).

  • templates (array) – Extracted heartbeat templates.

  • heart_rate_ts (array) – Heart rate time axis reference (seconds).

  • heart_rate (array) – Instantaneous heart rate (bpm).

  • units (str, optional) – Units of the vertical axis. If provided, the plot title will include the units information. Default is None.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_eda(ts=None, raw=None, filtered=None, edr=None, edl=None, onsets=None, peaks=None, amplitudes=None, units=None, path=None, show=False)[source]

Create a summary plot from the output of signals.eda.eda.

Parameters:
  • ts (array) – Signal time axis reference (seconds).

  • raw (array) – Raw EDA signal.

  • filtered (array) – Filtered EDA signal.

  • edr (array) – Electrodermal response signal.

  • edl (array) – Electrodermal level signal.

  • onsets (array) – Events onsets indices.

  • peaks (array) – Events peaks indices.

  • amplitudes (array) – Amplitudes location indices.

  • units (str, optional) – Units of the vertical axis. If provided, the plot title will include the units information. Default is None.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_eeg(ts=None, raw=None, filtered=None, labels=None, features_ts=None, theta=None, alpha_low=None, alpha_high=None, beta=None, gamma=None, plf_pairs=None, plf=None, path=None, show=False)[source]

Create a summary plot from the output of signals.eeg.eeg.

Parameters:
  • ts (array) – Signal time axis reference (seconds).

  • raw (array) – Raw EEG signal.

  • filtered (array) – Filtered EEG signal.

  • labels (list) – Channel labels.

  • features_ts (array) – Features time axis reference (seconds).

  • theta (array) – Average power in the 4 to 8 Hz frequency band; each column is one EEG channel.

  • alpha_low (array) – Average power in the 8 to 10 Hz frequency band; each column is one EEG channel.

  • alpha_high (array) – Average power in the 10 to 13 Hz frequency band; each column is one EEG channel.

  • beta (array) – Average power in the 13 to 25 Hz frequency band; each column is one EEG channel.

  • gamma (array) – Average power in the 25 to 40 Hz frequency band; each column is one EEG channel.

  • plf_pairs (list) – PLF pair indices.

  • plf (array) – PLF matrix; each column is a channel pair.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_egm(ts=None, raw=None, filtered=None, rhythm=None, active_regions=None, ts_windowed=None, windowed=None, lat_index=None, lat=None, df=None, freqs=None, power=None, entropy=None, oi=None, ri=None, units=None, path=None, show=False)[source]

Create a summary plot from the output of signals.egm.egm.

Parameters:
  • ts (array) – Signal time axis reference (seconds).

  • raw (array) – Raw EGM signal.

  • filtered (array) – Filtered EGM signal.

  • rhythm (str) – Rhythm of the EGM signal. Must be ‘sinus’ or ‘af’.

  • active_regions (array) – Active regions of the EGM signal.

  • ts_windowed (array, optional) – Signal time axis reference (seconds) for windowed signal.

  • windowed (array, optional) – Windowed EGM signal.

  • act (int, optional) – Index corresponding to the activation time of the EGM signal.

  • lat (float, optional) – Activation time in milliseconds (ms).

  • df (float, optional) – Dominant frequency of the EGM signal (Hz).

  • freqs (array, optional) – Frequencies of the dominant frequency spectrum.

  • power (array, optional) – Power of the dominant frequency spectrum.

  • entropy (float, optional) – Entropy of the EGM signal.

  • oi (float, optional) – Organization index of the EGM signal.

  • ri (float, optional) – Regularity index of the EGM signal.

  • units (str, optional) – Units of the vertical axis. If provided, the plot title will include the units information. Default is None.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_emg(ts=None, sampling_rate=None, raw=None, filtered=None, onsets=None, processed=None, units=None, path=None, show=False)[source]

Create a summary plot from the output of signals.emg.emg.

Parameters:
  • ts (array) – Signal time axis reference (seconds).

  • sampling_rate (int, float) – Sampling frequency (Hz).

  • raw (array) – Raw EMG signal.

  • filtered (array) – Filtered EMG signal.

  • onsets (array) – Indices of EMG pulse onsets.

  • processed (array, optional) – Processed EMG signal according to the chosen onset detector.

  • units (str, optional) – Units of the vertical axis. If provided, the plot title will include the units information. Default is None.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_filter(ftype='FIR', band='lowpass', order=None, frequency=None, sampling_rate=1000.0, log_xscale=True, path=None, show=True, **kwargs)[source]

Plot the frequency response of the filter specified with the given parameters.

Parameters:
  • ftype (str) –

    Filter type:
    • Finite Impulse Response filter (‘FIR’);

    • Butterworth filter (‘butter’);

    • Chebyshev filters (‘cheby1’, ‘cheby2’);

    • Elliptic filter (‘ellip’);

    • Bessel filter (‘bessel’).

  • band (str) –

    Band type:
    • Low-pass filter (‘lowpass’);

    • High-pass filter (‘highpass’);

    • Band-pass filter (‘bandpass’);

    • Band-stop filter (‘bandstop’).

  • order (int) – Order of the filter.

  • frequency (int, float, list, array) –

    Cutoff frequencies; format depends on type of band:
    • ’lowpass’ or ‘bandpass’: single frequency;

    • ’bandpass’ or ‘bandstop’: pair of frequencies.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • log_xscale (bool, optional) – Whether to use log scale for x-axis.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

  • **kwargs (dict, optional) – Additional keyword arguments are passed to the underlying scipy.signal function.

biosppy.plotting.plot_hrv(rri, rri_trend=None, td_out=None, nl_out=None, fd_out=None, show=False)[source]

Create a summary plot of a HRV analysis.

Parameters:
  • rri (array) – RR-intervals (ms).

  • rri_trend (array, optional) – RR-intervals trend (ms).

  • td_out (dict) – Output of signals.hrv.timedomain.

  • nl_out (dict) – Output of signals.hrv.nonlinear.

  • fd_out (dict) – Output of signals.hrv.frequencyomain.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_hrv_fbands(frequencies=None, powers=None, fbands=None, method_name=None, legends=None, ax=None, show=False)[source]

Plots the power spectrum and highlights the defined frequency bands from the output of signals.hrv.compute_fbands.

Parameters:
  • frequencies (array) – Frequency axis.

  • powers (array) – Power spectrum values for the frequency axis.

  • fbands (dict, optional) – Dictionary containing the limits of the frequency bands.

  • method_name (str, optional) – Method that was used to compute the power spectrum.

  • legends (dict, optional) – Additional legend elements.

  • ax (axis, optional) – Plot Axis to use.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_hrv_hist(rri=None, bins=None, q_hist=None, hti=None, tinn=None, ax=None, show=False)[source]

Plots the RRI histogram with the corresponding geometrical HRV features from the output of signals.hrv.compute_geometrical.

Parameters:
  • rri (array) – RR-intervals (ms).

  • bins (array) – Histogram bins.

  • q_hist (array) – Multilinear function fitted to the histogram.

  • hti (float) – HTI - HRV triangular index - Integral of the density of the RR interval histogram divided by its height.

  • tinn (float) – TINN - Baseline width of RR interval histogram (ms).

  • ax (axis, optional) – Plot Axis to use.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_pcg(ts=None, raw=None, filtered=None, peaks=None, heart_sounds=None, heart_rate_ts=None, inst_heart_rate=None, units=None, path=None, show=False)[source]

Create a summary plot from the output of signals.pcg.pcg.

Parameters:
  • ts (array) – Signal time axis reference (seconds).

  • raw (array) – Raw PCG signal.

  • filtered (array) – Filtered PCG signal.

  • peaks (array) – Peak location indices.

  • heart_sounds (array) – Classification of peaks as S1 or S2

  • heart_rate_ts (array) – Heart rate time axis reference (seconds).

  • inst_heart_rate (array) – Instantaneous heart rate (bpm).

  • units (str, optional) – Units of the vertical axis. If provided, the plot title will include the units information. Default is None.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_poincare(rri=None, s=None, sd1=None, sd2=None, legends=None, ax=None, show=False)[source]

Plot a Poincaré plot of a series of RR intervals (RRI[i+1] vs. RRI[i]) from the output of signals.hrv.compute_poincare.

Parameters:
  • rri (array) – RR-intervals (ms).

  • s (float) – S - Area of the ellipse of the Poincaré plot (ms^2).

  • sd1 (float) – SD1 - Poincaré plot standard deviation perpendicular to the identity line (ms).

  • sd2 (float) – SD2 - Poincaré plot standard deviation along the identity line (ms).

  • legends (dict, optional) – Dictionary of features to add to the plot legend.

  • ax (axis, optional) – Plot Axis to use.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_ppg(ts=None, raw=None, filtered=None, peaks=None, templates_ts=None, templates=None, heart_rate_ts=None, heart_rate=None, units=None, path=None, show=False)[source]

Create a summary plot from the output of signals.ppg.ppg.

Parameters:
  • ts (array) – Signal time axis reference (seconds).

  • raw (array) – Raw PPG signal.

  • filtered (array) – Filtered PPG signal.

  • peaks (array) – Indices of PPG pulse peaks.

  • templates_ts (array) – Templates time axis reference (seconds).

  • templates (array) – Extracted PPG templates.

  • heart_rate_ts (array) – Heart rate time axis reference (seconds).

  • heart_rate (array) – Instantaneous heart rate (bpm).

  • units (str, optional) – Units of the vertical axis. If provided, the plot title will include the units information. Default is None.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_resp(ts=None, raw=None, filtered=None, zeros=None, resp_rate_ts=None, resp_rate=None, units=None, path=None, show=False)[source]

Create a summary plot from the output of signals.ppg.ppg.

Parameters:
  • ts (array) – Signal time axis reference (seconds).

  • raw (array) – Raw Resp signal.

  • filtered (array) – Filtered Resp signal.

  • zeros (array) – Indices of Respiration zero crossings.

  • resp_rate_ts (array) – Respiration rate time axis reference (seconds).

  • resp_rate (array) – Instantaneous respiration rate (Hz).

  • units (str, optional) – Units of the vertical axis. If provided, the plot title will include the units information. Default is None.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_rri(rri, rri_trend=None, legends=None, ax=None, show=False)[source]

Plot a series of RR intervals.

Parameters:
  • rri (array) – RR-intervals (ms).

  • rri_trend (array, optional) – RR-intervals trend (ms).

  • legends (dict, optional) – Dictionary of features to add to the plot legend.

  • ax (axis, optional) – Plot Axis to use.

  • show (bool, optional) – If True, show the plot immediately.

biosppy.plotting.plot_spectrum(signal=None, sampling_rate=1000.0, path=None, show=True)[source]

Plot the power spectrum of a signal (one-sided).

Parameters:
  • signal (array) – Input signal.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show the plot immediately.