-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlive_data_plotter.py
More file actions
34 lines (32 loc) · 875 Bytes
/
live_data_plotter.py
File metadata and controls
34 lines (32 loc) · 875 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
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
style.use('fivethirtyeight')
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ax2 = fig.add_subplot(1,2,1)
ax3 = fig.add_subplot(2,1,1)
ax4 = fig.add_subplot(2,2,1)
def animate(i):
graph_data = open('log_data.csv','r').read()
lines = graph_data.split('\n')
xs = []
q1s = []
q2s = []
q3s = []
q4s = []
for j, line in enumerate(lines):
if len(line) > 1:
q1, q2, q3, q4 = line.split(',')
xs.append(j)
q1s.append(float(q1))
q2s.append(float(q2))
q3s.append(float(q3))
q4s.append(float(q4))
ax1.clear()
ax1.plot(xs, q1s)
ax2.plot(xs, q2s)
ax3.plot(xs, q3s)
ax4.plot(xs, q4s)
ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()