Saturday, January 1, 2022

Make a WordCloud in Python

 Here is how to make something like this image below in python with less than ten lines of code. It is called "WordCloud" and it is a visual representations of words that give greater prominence to words that appear more frequently.


You need to install WordCloud and MatPlotLib libraries to run the code blow.

Make a list of text you want to use for the word cloud and generate it as seen below.

# Libraries
%matplotlib notebook
from wordcloud import WordCloud
import matplotlib.pyplot as plt
 
# Create a list of word
text=("Umar Umar Umar 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, margin=0).generate(text)
 
# Display the generated image:
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.margins(x=0, y=0)
plt.show()

That is it!

No comments:

Post a Comment