def get_plot(limit, txt, wc_mask=wc_mask, stop = english_stopwords):
wordcloud = WordCloud(
max_words=limit,
stopwords=stop,
mask=wc_mask
).generate(txt)
fig = plt.figure()
fig.set_figwidth(8)
fig.set_figheight(8)
plt.imshow(wordcloud, interpolation="bilinear")
plt.axis('off')
figfile = BytesIO()
plt.savefig(figfile, format='png')
figfile.seek(0)
figdata_png = base64.b64encode(figfile.getvalue()).decode()
return figdata_png
评论列表
文章目录