Skip to content

Commit aaa984e

Browse files
author
Benjamin Moody
committed
plot_items: use "frames" instead of "samples" if required.
If sharex is true, the time units must be the same for all channels in order to have a correctly time-aligned plot. Therefore, if the caller specified time_units="samples", sharex=True, and a list of heterogeneous sampling frequencies, then automatically switch to using "frames" instead.
1 parent d220f14 commit aaa984e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

wfdb/plot/plot.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ def plot_items(
254254
sampling_freq = _get_sampling_freq(sampling_freq, n_sig, frame_freq)
255255
ann_freq = _get_ann_freq(ann_freq, n_annot, frame_freq)
256256

257+
# If plotting a multi-frequency record in 'sharex' mode, the time units
258+
# must be the same for all channels; therefore, if "samples" are
259+
# requested, use "frames" instead.
260+
if (
261+
time_units == "samples"
262+
and sharex
263+
and frame_freq is not None
264+
and any(f != frame_freq for f in sampling_freq)
265+
):
266+
time_units = "frames"
267+
257268
# Create figure
258269
fig, axes = _create_figure(n_subplots, sharex, sharey, figsize)
259270
try:

0 commit comments

Comments
 (0)