-
Notifications
You must be signed in to change notification settings - Fork 2
/
plot_graph.py
42 lines (34 loc) · 901 Bytes
/
plot_graph.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
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
import time
style.use("ggplot")
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
def animate(i):
pullData = open("twitter-out.txt","r").read()
lines = pullData.split('\n')
xar = []
yar = []
zar=[]
x = 0
y = 0
z = 0
for l in lines[:]:
x += 1
if "pos" in l:
y += 1
elif "neg" in l:
#y -= 1
z+=1
xar.append(x)
yar.append(y)
zar.append(z)
ax1.clear()
ax1.plot(xar,yar,label="positive",)
ax1.plot(xar,zar,label="negative")
plt.xlabel('Total number of tweets')
plt.ylabel('Respective count of each sentiment');
plt.legend(loc='best')
ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()