import matplotlib.pyplot as plt
from wordcloud import WordCloud
from wordcloud import STOPWORDS
import numpy as np
from PIL import Image
text = open("/Users/aiden/Desktop/data/output_pos.txt").read()
#text = text.decode('cp494').encode('UTF-8')
wordcloud = WordCloud(max_font_size=50).generate(text)
#print(wordcloud.words_)
#plt.figure(figsize = (10,10)) #총 그림 사이즈
#plt.imshow(wordcloud, interpolation = 'bilinear')
#plt.axis("off") # axis off
#plt.show()
mask = np.array(Image.open("/Users/aiden/Desktop/Python/Wordcloud/images/Sherlock1.jpg"))
stopwords = set(STOPWORDS)
stopwords.add("WELL")
#plt.figure(figsize=(10,10))
#plt.imshow(sherlock_mask, cmap=plt.cm.gray, interpolation = 'bilinear')
#plt.axis("off")
#plt.show()
#font_path='/System/Library/Fonts/ytte08-1361843442.ttf'
wc = WordCloud(background_color = "white", max_words = 2000, mask = mask, stopwords = stopwords)
wc = wc.generate(text)
#wc.to_file(path.join(d, "frozen.jpg"))
#wc.words_ # 문서에서 단어뽑기
plt.figure(figsize=(8,8))
plt.imshow(wc, interpolation = 'bilinea![](https://t1.daumcdn.net/cfile/cafe/99A1C6355A41CC2F28)
![](https://t1.daumcdn.net/cfile/cafe/99A573355A41CC2F27)
r')
plt.axis("off")
plt.show()