Plotting sentiment scores
Lastly, let's plot the sentiment of each hashtag over time. This is largely similar to plotting the prevalence of tweets.
Bài tập này là một phần của khóa học
Analyzing Social Media Data in Python
Hướng dẫn bài tập
- Plot a line for
#pythonusage withsentiment_py. Usesentiment_py.index.dayas the x-axis. - Do the same with
sentiment_r.
Bài tập tương tác thực hành trực tiếp
Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.
# 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()