def generate_wordcloud(words_list, mask_path):
text = ' '.join(words_list)
# print text
mask = np.array(Image.open(mask_path))
# stopwords = set(STOPWORDS)
# stopwords.add(u'')
wc = WordCloud(font_path = 'data/SourceHanSerifCN-Regular.otf', background_color = 'white',
max_words = 2000, mask = mask) # ??????????
wc.generate(text)
# wc.to_file('data/path/to/file')
plt.imshow(wc, interpolation='bilinear')
plt.axis("off")
plt.show()
评论列表
文章目录