Get startedGet started for free

Visualizing word frequencies

Now that you've computed the most frequent words with and without stop words, it's time to visualize the differences. In this exercise, you'll use matplotlib to plot bar charts for both cases.

The following lists have been pre-loaded for you: top_words_without_stopwords, top_counts_without_stopwords, top_words_with_stopwords, top_counts_with_stopwords.

This exercise is part of the course

Natural Language Processing (NLP) in Python

View Course

Exercise instructions

  • Use plt.bar() to plot the top 10 word frequencies with stop words.
  • Use plt.bar() to plot the top 10 word frequencies without stop words.

Hands-on interactive exercise

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

import matplotlib.pyplot as plt
# Plot the frequencies with stop words
plt.bar(____, ____)
plt.title("Top 10 word frequencies (with stop words)")
plt.xlabel("Words")
plt.ylabel("Frequency")
plt.show()

# Plot the frequencies without stop words
plt.figure()
plt.bar(____, ____)
plt.title("Top 10 word frequencies (without stop words)")
plt.xlabel("Words")
plt.ylabel("Frequency")
plt.show()
Edit and Run Code