wordcloud

Create Word Cloud Using Python

We are talking about Anime Word Cloud here.

Obviously, it will be created using Python.

How To Create a Word Cloud Using Python?

What Is A Word cloud?

A Word Cloud is a bunch of shuffled words. The simple term which can be used here is collage. These words are graphically represented with stunning random colors/specific shapes. The word clouds are also known as Tag Clouds.

The visualization of word cloud can assist evaluators with exploratory textual analysis by identifying words that frequently appear in a set of interviews, documents, or other text. It can also be used for communicating the most salient points or themes in the reporting stage.

Install the necessary Python library.

pip install wordcloud
pip install matplotlib
pip install pandas

Word Cloud Python

Once you have the Word Cloud Python library installed. Wordcloud has graphically represented words, when you use graphically it is pretty obvious we need Matplotlib. You will need the Matplotlib library to visualize the Word Cloud image.

When I say Matplotlib library, it’s obvious that you need a Jupyter Notebook installed in your local system. However, you will need a dataset with Anime names or characters list. For the names dataset, you either Web Scrap the data and create a CSV file. You can check this article to Web Scrape data and Create a CSV file. If you still are not familiar with Web scraping you can directly download the dataset.

file = pd.read_csv("Best 50 anime of all time.csv")
data = pd.DataFrame(file)
names = data.Title

Since we are dealing with a CSV file, another library comes into the picture. You will require the pandas’ library to read the CSV file. Visualize the Word Cloud with simple Python code

The major drawback of using Word Cloud is that the color and shape generated might be weird. While generating the Word cloud using Python you might get disappointed when your favorite anime gets less font size. Predicting the font size for a particular word while generating word cloud is difficult.

stopwords = set(STOPWORDS) 

#get the text

name = [anime for anime in data.Title]
    
wordclouds = WordCloud(width = 1200, height = 720, 
                background_color ='white',collocations=False,
                stopwords = stopwords,random_state = 42, 
                max_font_size=60)

wordclouds.generate(''.join(name)) 
  
# plot the WordCloud image 

plt.figure(figsize=(10,8)) 
plt.imshow(wordclouds,interpolation=None) 
plt.axis("off")
plt.tight_layout(pad = 0) 

# save the image 
plt.savefig("anime_word_cloud.png")

Conclusion

You can use Anime Word Cloud to visualize your favorite Anime names or Favourite Characters. You could even create a word cloud for those anime which is still pending in your watch list.

Download the source code for the above project.

Do you like the Anime Vyuh Content? Support us by buying a coffee.

Leave a Comment

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.