Skip to content

Instantly share code, notes, and snippets.

@mlai-demo
Created August 11, 2019 22:45
Show Gist options
  • Save mlai-demo/204c1d2e3c58d9244fd4ad6cee9534c4 to your computer and use it in GitHub Desktop.
Save mlai-demo/204c1d2e3c58d9244fd4ad6cee9534c4 to your computer and use it in GitHub Desktop.
import pandas as pd
from wordcloud import WordCloud
import matplotlib.pyplot as plt
from os import path
d = path.dirname(__file__) if "__file__" in locals() else os.getcwd()
text_standard = open(fpath + '/Plutarch_tokens.txt', 'rt').read()
wc = WordCloud(stopwords=stop_words,
max_font_size=200,
width=2500,
height=2000,
max_words=4000,
random_state=44,
).generate(text_standard)
wc.to_file(path.join(d, "wc.png")) #comment out if no need to store the png
fig = plt.figure().set_size_inches(18, 18)
plt.imshow(wc, interpolation="bilinear")
plt.axis("off")
plt.title("Plutarch's Lives", fontsize= 20)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment