Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. class CreateGraph():
  2.  
  3. def construct(self):
  4. xar=[]
  5. yar=[]
  6. graph=plt.plot(xar,yar)[0]
  7. plt.ion()
  8. plt.axis([0,1,0,50])
  9. plt.ylabel("Sentiment")
  10. plt.xlabel("Number of Tweets")
  11. plt.show()
  12. plt.pause(0.001)
  13.  
  14. return graph
  15.  
  16. class UpdateGraph():
  17.  
  18. def __init__(self,graph):
  19. #self.fig=plt.figure()
  20. #self.ax1=self.fig.add_subplot(1,1,1)
  21. self.xar=[]
  22. self.yar=[]
  23.  
  24. #self.h1=self.ax1.plot(self.xar, self.yar)[0]
  25.  
  26. def update_plot(self):
  27. graph_data=open("twitter-out.txt", "r")
  28. graph_data=list(graph_data)
  29. graph_data=graph_data[0].split(",")
  30. x=0
  31. y=0
  32. for l in graph_data:
  33. x+=1
  34. y=float(l)
  35. self.xar.append(x)
  36. self.yar.append(y)
  37.  
  38. graph.set_xdata(self.xar)
  39. graph.set_ydata(self.yar)
  40. print(graph)
  41. graph.draw()
  42. graph.pause(0.001)
  43.  
  44. Failed: draw_wrapper() missing 1 required positional argument: 'renderer'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement