-
Notifications
You must be signed in to change notification settings - Fork 13
/
plot.py
64 lines (55 loc) · 2.06 KB
/
plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import matplotlib.pyplot as plt
def plot(y, title="Signal", xLab="Index * 0.003s", yLab="mV", size=(9.7,6)):
fig = plt.figure(figsize=size) # I used figures to customize size
ax = fig.add_subplot(111)
ax.plot(y)
ax.set_title(title)
# fig.savefig('/Users/samy/Downloads/{0}.png'.format(self.name))
ax.set_ylabel(yLab)
ax.set_xlabel(xLab)
plt.show()
def plotBaseline(y, baseline=0, title="Signal", xLab="Index * 0.003s", yLab="mV", size=(9.7,6)):
fig = plt.figure(figsize=size) # I used figures to customize size
ax = fig.add_subplot(111)
ax.plot(y)
ax.set_title(title)
# fig.savefig('/Users/samy/Downloads/{0}.png'.format(self.name))
plt.axhline(y=baseline)
ax.set_ylabel(yLab)
ax.set_xlabel(xLab)
plt.show()
def multiplot(data, graph_names):
#plot multiple lines in one graph
# input:
# data = list of data to plot
# graph_names = list of record names to show in the legend
for l in data:
plt.plot(l)
plt.legend(graph_names)
plt.show()
def plotRPeaks(signal):
fig = plt.figure(figsize=(9.7, 6)) # I used figures to customize size
ax = fig.add_subplot(111)
ax.plot(signal.data)
# ax.axhline(self.baseline)
ax.plot(*zip(*signal.RPeaks), marker='o', color='r', ls='')
ax.set_title(signal.name)
# fig.savefig('/Users/samy/Downloads/{0}.png'.format(self.name))
plt.show()
def plotCoords(data, coords):
fig = plt.figure(figsize=(9.7, 6)) # I used figures to customize size
ax = fig.add_subplot(111)
ax.plot(data)
ax.plot(*zip(*coords), marker='o', color='r', ls='')
plt.show()
def plotBins(bins, recordTitle=""):
fig = plt.figure(figsize=(9.7, 6))
ax = fig.add_subplot(111)
rects1 = ax.bar(0.5, bins[0], color='r')
rects2 = ax.bar(1.5, bins[1], color='b')
rects3 = ax.bar(2.5, bins[2], color='g')
ax.legend((rects1[0], rects2[0], rects3[0]), ('bin 1', 'bin 2', 'bin 3'))
ax.set_ylabel('Bin percent')
ax.set_xlabel('Bins')
ax.set_title('RR Interval bins' + recordTitle)
plt.show()