Created
March 14, 2019 09:13
-
-
Save cosmos-sajal/7f737102fbd69cff258c11451b601212 to your computer and use it in GitHub Desktop.
Plotting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
import time | |
fig = plt.figure() | |
ax1 = fig.add_subplot(1,1,1) | |
def animate(i): | |
# Donald Trump's tweet results were in twitter-out.txt | |
# Hillary Clinton's tweet results were in twitter-out1.txt | |
pullData = open("twitter-out.txt","r").read() | |
lines = pullData.split('\n') | |
print len(lines) | |
xar = [] | |
yar = [] | |
x = 0 | |
y = 0 | |
for l in lines[0:len(lines)]: | |
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