Home
/
API Reference
/
Plotting API Reference Plotting API Reference Import: from ecgdatakit.plotting import ...
Static plots require: pip install ecgdatakit[plotting] (matplotlib ≥ 3.7)
Interactive plots require: pip install ecgdatakit[plotting-interactive] (plotly ≥ 5.15)
Static Plots (matplotlib) All functions return matplotlib.figure.Figure. Functions with an ax parameter can render into an existing axes for composability. When ax=None, a new figure is created.
Function Description plot_lead(lead, peaks=None, title=None, show_grid=True, figsize=(12,3), ax=None)Single lead waveform with optional R-peak markers. ECG-style grid with major lines every 0.2s / 0.5mV. plot_leads(leads, peaks_dict=None, title=None, show_grid=True, figsize=(12,None), share_x=True)Multiple leads stacked vertically, shared X-axis. Accepts list[Lead] or ECGRecord. Height auto-calculated. plot_12lead(leads, record=None, paper_speed=25, amplitude=10, rhythm_lead="II", duration=10.0, figsize=(14,10))Standard 12-lead grid (4×3) with rhythm strip. Paper-style grid. Optional header with patient info and measurements when record is provided. Accepts list[Lead] or ECGRecord.
from ecgdatakit.plotting import plot_12lead
# From an ECGRecord (header with patient info)
fig = plot_12lead ( record )
fig . savefig ( "ecg_grid.png" , dpi = 150 )
# From a list of leads (no header)
fig = plot_12lead ( record . leads )
Annotations & Beats Function Description plot_peaks(lead, peaks=None, title=None, figsize=(12,3), ax=None)Lead with R-peak triangles, RR interval annotations between peaks, and heart rate in corner. Auto-detects peaks if None. plot_beats(lead, beats=None, peaks=None, overlay=True, figsize=(8,5), ax=None)Segmented heartbeats. overlay=True: all beats on same axes (semi-transparent) with average bold. overlay=False: waterfall/stacked. plot_average_beat(lead, peaks=None, before=0.2, after=0.4, figsize=(6,4), ax=None)Ensemble-averaged beat with shaded ±1 SD region. X-axis in ms relative to R-peak.
Frequency Domain Function Description plot_spectrum(lead, method="welch", figsize=(10,4), ax=None)"welch": PSD in dB/Hz. "fft": magnitude spectrum. Shaded ECG band (0.05–150 Hz).plot_spectrogram(lead, nperseg=256, figsize=(12,4), ax=None)Time-frequency spectrogram (STFT) as a colormap. X: time, Y: frequency, color: power.
HRV Function Description plot_rr_tachogram(rr_ms, figsize=(10,3), ax=None)RR intervals vs. beat number with mean ± SD reference lines. plot_poincare(rr_ms, figsize=(6,6), ax=None)Poincaré plot: RR(n) vs RR(n+1) with SD1/SD2 ellipse and identity line. plot_hrv_summary(rr_ms, figsize=(14,8))4-panel dashboard: RR tachogram, Poincaré plot, frequency-domain PSD with VLF/LF/HF bands shaded, and time-domain metrics table.
Quality Function Description plot_quality(leads, figsize=(10,5))Bar chart of signal quality index per lead. Color-coded: green (excellent), yellow (acceptable), red (unacceptable). SNR annotated.
Full Report Function Description plot_report(record, figsize=(16,20))Comprehensive ECG report: patient header, measurements table, 12-lead grid, rhythm strip, quality summary, and interpretation statements.
from ecgdatakit.plotting import plot_report
fig = plot_report ( record )
fig . savefig ( "full_report.pdf" )
Interactive Plots (plotly) All functions return plotly.graph_objects.Figure. Features: zoom, pan, hover with sample-level values, range sliders.
Function Description iplot_lead(lead, peaks=None, title=None, height=300)Interactive single lead with rangeslider, crosshair spikes, hover showing time and amplitude. iplot_leads(leads, peaks_dict=None, title=None, height=None)Stacked leads with synchronized X-axis zoom. Toggle visibility via legend. Accepts list[Lead] or ECGRecord. iplot_12lead(leads, record=None, duration=10.0, height=800)Interactive 4×3 grid + rhythm strip. Header annotation when record provided.
from ecgdatakit.plotting import iplot_lead , iplot_12lead
# Single lead with peaks
fig = iplot_lead ( filtered , peaks = peaks )
fig . show ()
# Full 12-lead interactive
fig = iplot_12lead ( record )
fig . show ()
Annotations Function Description iplot_peaks(lead, peaks=None, title=None, height=350)Lead with R-peak markers. Hover shows peak index, RR interval, and instantaneous HR.
Frequency Domain Function Description iplot_spectrum(lead, method="welch", height=400)Interactive spectrum with hover showing frequency and power. Shaded ECG band.
HRV Function Description iplot_rr_tachogram(rr_ms, height=300)Interactive RR tachogram with mean ± SD lines. Hover shows beat number and RR value. iplot_poincare(rr_ms, height=500)Interactive Poincaré with SD1/SD2 ellipse. Hover shows beat pair indices and RR values.
Full Report Function Description iplot_report(record, height=1200)Full interactive report with all leads, rhythm strip with rangeslider, and header annotation.
← Previous
Processing