A basic wordcloud can be generated from text using the WordCloud() object of the wordcloud library with the generate(text) method. The parameters used in this example are:

  • width : width of the canvas
  • height : height of the canvas
# Libraries
from wordcloud import WordCloud
import matplotlib.pyplot as plt
# Create a list of word
text=("""Python Python Python Matplotlib Matplotlib Seaborn
      Network Plot Violin Chart Pandas Datascience Wordcloud
      Spider Radar Parrallel Alpha Color Brewer Density Scatter
      Barplot Barplot Boxplot Violinplot Treemap Stacked Area
      Chart Chart Visualization Dataviz Donut Pie Time-Series
      Wordcloud Wordcloud Sankey Bubble""")
# Create the wordcloud object
wordcloud = WordCloud(width=480, height=480).generate(text)
# Display the generated image:
plt.imshow(wordcloud, interpolation='bilinear')
plt.margins(x=0, y=0)

Going further

Discover how to customize your wordcloud by changing size, color and more and using a shape mask.

Contact & Edit

👋 This document is a work by Yan Holtz. You can contribute on github, send me a feedback on twitter or subscribe to the newsletter to know when new examples are published! 🔥

This page is just a jupyter notebook, you can edit it here. Please help me making this website better 🙏!