python list

Python | Word Cloud.

The word cloud is one of the interesting techniques for data visualization like infographic charts, graphs, etc. Word cloud could be the best option when analyzing customer’s and employee’s sentiments, Search engine optimization, pattern analysis of the large text, a quick overview of data, etc. In this tutorial, we are going to learn how to generate a word cloud from a text file using python.

Please make sure you have a python environment with worldcloud and matplotlib modules installed in it. If you have not installed these modules yet, you can install them by the following command.


pip install worldcloud


pip install matplotlib

Now we have all the required python modules to generate the word cloud. For the demo purpose, we are going to use the below sample text file. You can get it by clicking the download button or you can also use your own text file as well.

Source code:

import matplotlib.pyplot as plt
from wordcloud import WordCloud
wordcloud = WordCloud( background_color = ‘white’,
                            width = 1200,
                            height = 1000,

Now save the file( and run it as shown in the snapshot below.


As shown in the above snapshot you can save the output in different formats (png, jpeg, jpg, pdf, etc.) by clicking the save button.