@@ -315,6 +315,13 @@ def label_figure(axes, n_subplots, time_units, sig_name, sig_units, ylabel,
315
315
316
316
ylabel = ['/' .join (pair ) for pair in zip (sig_name , sig_units )]
317
317
318
+ # If there are annotations with channels outside of signal range
319
+ # put placeholders
320
+ n_missing_labels = n_subplots - len (ylabel )
321
+ if n_missing_labels :
322
+ ylabel = ylabel + ['ch_%d/NU' % i for i in range (len (ylabel ),
323
+ n_subplots )]
324
+
318
325
for ch in range (n_subplots ):
319
326
axes [ch ].set_ylabel (ylabel [ch ])
320
327
@@ -353,14 +360,15 @@ def plot_wfdb(record=None, annotation=None, plot_sym=False,
353
360
plot_sym : bool, optional
354
361
Whether to plot the annotation symbols on the graph.
355
362
time_units : str, optional
356
- The x axis unit. Allowed options are: 'samples', 'seconds', 'minutes',
357
- and 'hours'.
363
+ The x axis unit. Allowed options are: 'samples', 'seconds',
364
+ 'minutes', and 'hours'.
358
365
title : str, optional
359
366
The title of the graph.
360
367
sig_style : list, optional
361
- A list of strings, specifying the style of the matplotlib plot for each
362
- signal channel. If the list has a length of 1, the style will be used
363
- for all channels.
368
+ A list of strings, specifying the style of the matplotlib plot
369
+ for each signal channel. The list length should match the number
370
+ of signal channels. If the list has a length of 1, the style
371
+ will be used for all channels.
364
372
ann_style : list, optional
365
373
A list of strings, specifying the style of the matplotlib plot for each
366
374
annotation channel. If the list has a length of 1, the style will be
@@ -427,23 +435,17 @@ def get_wfdb_plot_items(record, annotation, plot_sym):
427
435
428
436
# Get annotation attributes
429
437
if annotation :
438
+ # Note: There may be instances in which the annotation `chan`
439
+ # attribute has non-overlapping channels with the signal.
440
+ # In this case, omit empty middle channels.
441
+
430
442
# Get channels
431
443
all_chans = set (annotation .chan )
432
444
433
445
n_chans = max (all_chans ) + 1
434
446
435
- # Just one channel. Place content in one list index.
436
- # if len(all_chans) == 1:
437
- # ann_samp = annotation.chan[0]*[None] + [annotation.sample]
438
- # if plot_sym:
439
- # ann_sym = annotation.chan[0]*[None] + [annotation.symbol]
440
- # else:
441
- # ann_sym = None
442
- # # Split annotations by channel
443
- # else:
444
-
445
447
# Indices for each channel
446
- chan_inds = n_chans * [np .empty (0 )]
448
+ chan_inds = n_chans * [np .empty (0 , dtype = 'int' )]
447
449
448
450
for chan in all_chans :
449
451
chan_inds [chan ] = np .where (annotation .chan == chan )[0 ]
0 commit comments