Plotting your Twitter data
Now that you have the number of tweets that each candidate was mentioned in, you can plot a histogram of this data and this is what you'll do in this final exercise.
Hopefully, you'll see that Trump was unreasonably represented! In the pre-exercise code, we have run the previous exercise solutions.
This exercise is part of the course
Importing Data in Python
Exercise instructions
- Import both
matplotlib.pyplotandseaborn, using the aliasespltandsns, respectively. - Complete the arguments of
sns.barplot: the first argument should be the labels to appear on the x-axis; the second argument should be the list of the numbers to appear on the y-axis, as produced in the previous exercise.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import packages
# Set seaborn style
sns.set(color_codes=True)
# Plot histogram
cd = ['clinton', 'trump', 'sanders', 'cruz']
ax = sns.barplot(____, ____)
ax.set(ylabel="count")
plt.show()