Skip to content

Instantly share code, notes, and snippets.

@josht-jpg
Last active September 2, 2020 20:03
Show Gist options
  • Save josht-jpg/05fdb57b348c0fc24d526236a34ec4a9 to your computer and use it in GitHub Desktop.
Save josht-jpg/05fdb57b348c0fc24d526236a34ec4a9 to your computer and use it in GitHub Desktop.
Plotting AFINN scores
def plot_afinn(df, title):
i = 0
scores = []
while i < df.shape[0] - 500:
scores.append(df.iloc[i:i + 500].loc[:, 'score'].sum())
i += 500
plt.plot(scores, c=np.random.rand(3,))
plt.ylabel("AFINN score")
plt.title(title)
plt.xticks([])
#y-axis limits were arrived at from the observed limits in the data.
#These should be changed if you're working with a different corpus.
plt.ylim(top = 165, bottom = -165)
plt.axhline(y = 0, color = 'gray')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment