Created
August 11, 2019 22:49
-
-
Save mlai-demo/53de2d2cb8545e1603d8fe7c454a22af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from PIL import Image | |
roman_mask = np.array(Image.open(path.join(d, 'roman7.png'))) | |
text_stem = open(fpath + '/Plutarch_stem.txt', 'rt').read() | |
wc = WordCloud(stopwords=stop_words, | |
max_font_size=200, | |
width=5000, | |
height=4000, | |
background_color="white", | |
max_words=4000, | |
mask=roman_mask, | |
contour_width=3, | |
contour_color='steelblue', | |
random_state = 64).generate(text_stem) | |
wc.to_file(path.join(d, "wc_stemmed.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 (Stemmed)", fontsize= 20) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment