Skip to content

Instantly share code, notes, and snippets.

@sayanmondal2098
Created April 1, 2018 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sayanmondal2098/b19e48d9bf45656b717f4457b2049641 to your computer and use it in GitHub Desktop.
Save sayanmondal2098/b19e48d9bf45656b717f4457b2049641 to your computer and use it in GitHub Desktop.
data visualisation
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("twitter6.txt","r").read()
lines = pullData.split('\n')
xar = []
yar = []
x = 0
y = 0
for l in lines[-200:]:
x += 1
if "pos" in l:
y += 1
elif "neg" in l:
y -= 1
xar.append(x)
yar.append(y)
ax1.clear()
ax1.plot(xar,yar)
ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment