Skip to content

Commit 13f5595

Browse files
committed
add symbol plotting option to plotrec for annotations. fixes MIT-LCP#78
1 parent 2dd9d50 commit 13f5595

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ Plotting Data
439439
::
440440

441441
plotrec(record=None, title = None, annotation = None, timeunits='samples',
442-
sigstyle='', figsize=None, returnfig = False, ecggrids=[]):
442+
sigstyle='', annstyle='r*', plotannsym=False, figsize=None,
443+
returnfig=False, ecggrids=[]):
443444

444445
Example Usage:
445446

@@ -461,6 +462,7 @@ Input Arguments:
461462
- ``timeunits`` (default='samples'): String specifying the x axis unit. Allowed options are: 'samples', 'seconds', 'minutes', and 'hours'.
462463
- ``sigstyle`` (default=''): String, or list of strings, specifying the styling of the matplotlib plot for the signals. If 'sigstyle' is a string, each channel will have the same style. If it is a list, each channel's style will correspond to the list element. ie. sigtype=['r','b','k'].
463464
- ``annstyle`` (default='r*'): String, or list of strings, specifying the styling of the matplotlib plot for the annotations. If 'annstyle' is a string, each channel will have the same style. If it is a list, each channel's style will correspond to the list element.
465+
- ``plotannsym`` (default=False): Specifies whether to plot the annotation symbols at their locations.
464466
- ``figsize`` (default=None): Tuple pair specifying the width, and height of the figure. Same as the 'figsize' argument passed into matplotlib.pyplot's figure() function.
465467
- ``returnfig`` (default=False): Specifies whether the figure is to be returned as an output argument
466468
- ``ecggrids`` (default=[]): List of integers specifying channels in which to plot ecg grids. May be set to [] for no channels, or 'all' for all channels. Major grids at 0.5mV, and minor grids at 0.125mV. All channels to be plotted with grids must have units equal to 'uV', 'mV', or 'V'.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Versions should comply with PEP440. For a discussion on single-sourcing
2121
# the version across setup.py and the project code, see
2222
# https://packaging.python.org/en/latest/single_source_version.html
23-
version='1.3.4',
23+
version='1.3.6',
2424

2525
description='The WFDB Python Toolbox',
2626
long_description=long_description,

wfdb/plot/plots.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
# Plot a WFDB Record's signals
1010
# Optionally, overlay annotation locations
11-
def plotrec(record=None, title = None, annotation = None, timeunits='samples', sigstyle='', annstyle='r*', figsize=None, returnfig = False, ecggrids=[]):
11+
def plotrec(record=None, title=None, annotation=None, timeunits='samples',
12+
sigstyle='', annstyle='r*', plotannsym=False, figsize=None, returnfig=False, ecggrids=[]):
1213
""" Subplot and label each channel of a WFDB Record.
1314
Optionally, subplot annotation locations over selected channels.
1415
@@ -32,6 +33,7 @@ def plotrec(record=None, title = None, annotation = None, timeunits='samples', s
3233
- annstyle (default='r*'): String, or list of strings, specifying the styling of the matplotlib plot for the annotations.
3334
If 'annstyle' is a string, each channel will have the same style. If it is a list, each channel's style will
3435
correspond to the list element.
36+
- plotannsym (default=False): Specifies whether to plot the annotation symbols at their locations.
3537
- figsize (default=None): Tuple pair specifying the width, and height of the figure. Same as the 'figsize' argument
3638
passed into matplotlib.pyplot's figure() function.
3739
- returnfig (default=False): Specifies whether the figure is to be returned as an output argument
@@ -87,6 +89,10 @@ def plotrec(record=None, title = None, annotation = None, timeunits='samples', s
8789
# Plot annotation if specified
8890
if annplot[ch] is not None:
8991
ax.plot(tann[ch], record.p_signals[annplot[ch], ch], annstyle[ch])
92+
# Plot the annotation symbols if specified
93+
if plotannsym:
94+
for i, s in enumerate(annotation.symbol):
95+
ax.annotate(s, (tann[ch][i], record.p_signals[annplot[ch], ch][i]))
9096

9197
# Axis Labels
9298
if timeunits == 'samples':

0 commit comments

Comments
 (0)