Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import pandas as pd
  2. from wordcloud import WordCloud
  3. import matplotlib.pyplot as plt
  4. from os import path
  5.  
  6. d = path.dirname(__file__) if "__file__" in locals() else os.getcwd()
  7.  
  8. text_standard = open(fpath + '/Plutarch_tokens.txt', 'rt').read()
  9.  
  10. wc = WordCloud(stopwords=stop_words,
  11. max_font_size=200,
  12. width=2500,
  13. height=2000,
  14. max_words=4000,
  15. random_state=44,
  16. ).generate(text_standard)
  17.  
  18. wc.to_file(path.join(d, "wc.png")) #comment out if no need to store the png
  19.  
  20. fig = plt.figure().set_size_inches(18, 18)
  21. plt.imshow(wc, interpolation="bilinear")
  22. plt.axis("off")
  23. plt.title("Plutarch's Lives", fontsize= 20)
  24. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement