-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphing.py
More file actions
45 lines (34 loc) · 764 Bytes
/
graphing.py
File metadata and controls
45 lines (34 loc) · 764 Bytes
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
import time
import matplotlib.pyplot as plt
from collections import deque
import sys
plt.ion()
ax = plt.subplot()
lines = {}
data_history= {}
pids = ["RBM", "New"]
for pid in pids:
line, = ax.plot([],[], label=pid)
lines[pid] = line
data_history[pid] = []
ax.set_xlabel("Time")
ax.set_ylabel("Value")
ax.set_title("Live Sensor Data")
ax.legend()
values = {
"RBM": [
1, 2, 3, 4,2 , 5, 6,3, 2,2
],
"New": [
3, 2, 1, 6,9 , 20, 10,3, 2,1
]
}
for pid in pids:
for v in values[pid]:
data_history[pid].append(v)
lines[pid].set_xdata(range(len(data_history[pid])))
lines[pid].set_ydata(list(data_history[pid]))
ax.relim()
ax.autoscale_view()
plt.pause(1)
input()