Skip to content

Commit 43662b8

Browse files
fix issue where rounding error leads to exception in plotting results
1 parent 62ec1a9 commit 43662b8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

heartpy/visualizeutils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,15 @@ def plotter(working_data, measures, show=True, figsize=None,
7979
# create plot x-var
8080
fs = working_data['sample_rate']
8181
plotx = np.arange(0, len(working_data['hr'])/fs, 1/fs)
82-
82+
#check if there's a rounding error causing differing lengths of plotx and signal
83+
diff = len(plotx) - len(working_data['hr'])
84+
if diff < 0:
85+
#add to linspace
86+
plotx = np.append(plotx, plotx[-1] + (plotx[-2] - plotx[-1]))
87+
elif diff > 0:
88+
#trim linspace
89+
plotx = plotx[0:-diff]
90+
8391
peaklist = working_data['peaklist']
8492
ybeat = working_data['ybeat']
8593
rejectedpeaks = working_data['removed_beats']

0 commit comments

Comments
 (0)