Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import matplotlib.animation as animation
  3. import time
  4.  
  5. fig = plt.figure()
  6. ax1 = fig.add_subplot(1,1,1)
  7.  
  8. def animate(i):
  9. # Donald Trump's tweet results were in twitter-out.txt
  10. # Hillary Clinton's tweet results were in twitter-out1.txt
  11. pullData = open("twitter-out.txt","r").read()
  12. lines = pullData.split('\n')
  13. print len(lines)
  14.  
  15. xar = []
  16. yar = []
  17.  
  18. x = 0
  19. y = 0
  20.  
  21. for l in lines[0:len(lines)]:
  22. x += 1
  23. if "pos" in l:
  24. y += 1
  25. elif "neg" in l:
  26. y -= 1
  27.  
  28. xar.append(x)
  29. yar.append(y)
  30.  
  31. ax1.clear()
  32. ax1.plot(xar,yar)
  33. ani = animation.FuncAnimation(fig, animate, interval=1000)
  34. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement