Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- from os import path
- from wordcloud import WordCloud
- d = path.dirname(__file__)
- # Read the whole text.
- text = open(path.join(d, 'adult.txt')).read()
- # Generate a word cloud image
- wordcloud = WordCloud().generate(text)
- # Display the generated image:
- # the matplotlib way:
- import matplotlib.pyplot as plt
- plt.imshow(wordcloud, interpolation='bilinear')
- plt.axis("off")
- # lower max_font_size
- wordcloud = WordCloud(max_font_size=40).generate(text)
- plt.figure()
- plt.imshow(wordcloud, interpolation="bilinear")
- plt.axis("off")
- plt.show()
- # The pil way (if you don't have matplotlib)
- # image = wordcloud.to_image()
- # image.show()
Add Comment
Please, Sign In to add comment