DEV Community

Cover image for how to create a word cloud in python?
Bhumi lad
Bhumi lad

Posted on • Edited on

how to create a word cloud in python?

if you don't have python.
download on below link:
python(https://www.python.org/downloads/)

and if you have then image of clapping

start word cloud
image of wordcloud

before starting the code, we have to install a module.
pip install wordcloud
or
conda install wordcloud

we need some libraries-
pip install matplotlib
pip install numpy

start creating wordcloud

code
so, we are imported modules and libraries...
and STOPWORDS is using to remove stopwords in the cloud, stop wards like is, are, HTTP etc.

code
we have to open a txt file in reading mode and set STOPWORD by creating variables.
you can create txt file by own in notepad.

code
you can download spyider pic using this link:
(https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.kissclipart.com%2Fspider-black-and-white-widow-spider-arachnid-line-8wkqnf%2F&psig=AOvVaw21JbV148DVgwKPNtOBXZt5&ust=1608631393595000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCNCEn9bp3u0CFQAAAAAdAAAAABAO)

Using a mask you can generate wordclouds in arbitrary shapes.so we take custom mask.you change background and word size. and generate text.

code
you must know about matplotlib library. if you don't know how it's work then click on this link :(https://matplotlib.org/3.3.3/contents.html#)
you can change figure size and if you have to save this wordcloud on your pc then save plt.savefig(text='MY wordcloud').you can use another name to save the image...

if you like this post like share and comment. Share your feedback, please
thank you

Top comments (0)