Get startedGet started for free

Plotting sentiment scores

Lastly, let's plot the sentiment of each hashtag over time. This is largely similar to plotting the prevalence of tweets.

This exercise is part of the course

Analyzing Social Media Data in Python

View Course

Exercise instructions

  • Plot a line for #python usage with sentiment_py. Use sentiment_py.index.day as the x-axis.
  • Do the same with sentiment_r.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import matplotlib
import matplotlib.pyplot as plt

# Plot average #python sentiment per day
plt.plot(____, ____, color = 'green')

# Plot average #rstats sentiment per day
plt.plot(____, ____, color = 'blue')

plt.xlabel('Day')
plt.ylabel('Sentiment')
plt.title('Sentiment of data science languages')
plt.legend(('#python', '#rstats'))
plt.show()
Edit and Run Code