Skip to content

Commit 2dd9d50

Browse files
committed
correct annotation location rounding when plotting time units in python2. fixes MIT-LCP#80
1 parent e09eeb9 commit 2dd9d50

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

wfdb/plot/plots.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from ..readwrite import _signals
66
from ..readwrite import annotations
77

8+
89
# Plot a WFDB Record's signals
910
# Optionally, overlay annotation locations
1011
def plotrec(record=None, title = None, annotation = None, timeunits='samples', sigstyle='', annstyle='r*', figsize=None, returnfig = False, ecggrids=[]):
@@ -286,11 +287,11 @@ def checkplotitems(record, title, annotation, timeunits, sigstyle, annstyle):
286287
if timeunits == 'samples':
287288
tann[ch] = annplot[ch]
288289
elif timeunits == 'seconds':
289-
tann[ch] = annplot[ch]/record.fs
290+
tann[ch] = annplot[ch]/float(record.fs)
290291
elif timeunits == 'minutes':
291-
tann[ch] = annplot[ch]/record.fs/60
292+
tann[ch] = annplot[ch]/float(record.fs)/60
292293
else:
293-
tann[ch] = annplot[ch]/record.fs/3600
294+
tann[ch] = annplot[ch]/float(record.fs)/3600
294295
else:
295296
tann = None
296297
annplot = [None]*record.nsig
@@ -370,11 +371,11 @@ def checkannplotitems(annotation, title, timeunits):
370371
if timeunits == 'samples':
371372
plotvals = annotation.sample
372373
elif timeunits == 'seconds':
373-
plotvals = annotation.sample/annotation.fs
374+
plotvals = annotation.sample/float(annotation.fs)
374375
elif timeunits == 'minutes':
375-
plotvals = annotation.sample/(annotation.fs*60)
376+
plotvals = annotation.sample/float(annotation.fs*60)
376377
elif timeunits == 'hours':
377-
plotvals = annotation.sample/(annotation.fs*3600)
378+
plotvals = annotation.sample/float(annotation.fs*3600)
378379

379380
# title
380381
if title is not None and not isinstance(title, str):

0 commit comments

Comments
 (0)