How To Create A Word Cloud In Python
Language:
In this tutorial, I will show you, how to create a Word Cloud in Python by using the library called “wordcloud”.
import matplotlib.pyplot as plt from wordcloud import WordCloud, STOPWORDS import sys, os os.chdir(sys.path[0]) # Read text text = open('jeff_bezos_speech.txt', mode='r', encoding='utf-8').read() stopwords = ['choice', 'will'] wc = WordCloud( background_color='white', stopwords=stopwords, height = 600, width=400 ) wc.generate(text) # store to file wc.to_file('wordcloud_output.png')