-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlive-plotting.py
41 lines (36 loc) · 1.02 KB
/
live-plotting.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
#draw the predictions from real-time.py
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)
def animate(i):
graph_data = open('emotion.txt', 'r').read()
lines = graph_data.split('\n')
xs = []
y_angry = []
y_fear = []
y_happy = []
y_sad = []
y_surprise = []
y_neutral = []
for line in lines:
if len(line) > 1:
time, angry, fear, happy, sad, surprise, neutral = line.split(',')
xs.append(time)
y_angry.append(angry)
y_fear.append(fear)
y_happy.append(happy)
y_sad.append(sad)
y_surprise.append(surprise)
y_neutral.append(neutral)
ax1.clear()
ax1.plot(xs, y_angry)
ax1.plot(xs, y_fear)
ax1.plot(xs, y_happy)
ax1.plot(xs, y_sad)
ax1.plot(xs, y_surprise)
ax1.plot(xs, y_neutral)
ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()