-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUI.py
33 lines (29 loc) · 861 Bytes
/
GUI.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
import matplotlib.pyplot as plt
class GUI:
def __init__(self, xlabel, ylabel, title) -> None:
self.data = [0]
self.x = [0]
self.x_label = xlabel
self.y_label = ylabel
self.title = title
self.fig = plt.gcf()
def update_data(self, inp):
self.data.append(self.data[-1] + inp)
if len(self.data) != 1:
self.x.append(len(self.data)-1)
def draw(self):
plt.plot(self.x, self.data)
plt.title(self.title)
plt.ylabel(self.y_label)
plt.xlabel(self.x_label)
plt.show(block=False)
plt.show()
def draw(plots):
for i, p in enumerate(plots):
plt.subplot(2, 1, i+1)
plt.plot(p.x, p.data)
plt.title(p.title)
plt.ylabel(p.y_label)
plt.xlabel(p.x_label)
plt.show(block=False)
plt.show()