from wordcloud import WordCloud import matplotlib.pyplot as plt text = "Hello world is a common phrase used in programming" wordcloud = WordCloud().generate(text) plt.imshow(wordcloud, interpolation='bilinear') plt.axis("off") plt.show()
from wordcloud import WordCloud import matplotlib.pyplot as plt import numpy as np from PIL import Image text = "Python is an easy-to-learn programming language" # Customizing the word cloud mask = np.array(Image.open("cloud.png")) font_path = "arial.ttf" wordcloud = WordCloud(background_color="white", mask=mask, contour_color="steelblue", contour_width=2, font_path=font_path).generate(text) plt.imshow(wordcloud, interpolation='bilinear') plt.axis("off") plt.show()In both examples, the package library used is 'wordcloud'.