Guest User

Untitled

a guest
Mar 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. from os import path
  4. from wordcloud import WordCloud
  5.  
  6. d = path.dirname(__file__)
  7.  
  8. # Read the whole text.
  9. text = open(path.join(d, 'adult.txt')).read()
  10.  
  11. # Generate a word cloud image
  12. wordcloud = WordCloud().generate(text)
  13.  
  14. # Display the generated image:
  15. # the matplotlib way:
  16. import matplotlib.pyplot as plt
  17. plt.imshow(wordcloud, interpolation='bilinear')
  18. plt.axis("off")
  19.  
  20. # lower max_font_size
  21. wordcloud = WordCloud(max_font_size=40).generate(text)
  22. plt.figure()
  23. plt.imshow(wordcloud, interpolation="bilinear")
  24. plt.axis("off")
  25. plt.show()
  26.  
  27. # The pil way (if you don't have matplotlib)
  28. # image = wordcloud.to_image()
  29. # image.show()
Add Comment
Please, Sign In to add comment