词云

from wordcloud import WordCloud, STOPWORDS
from matplotlib import pyplot as plt
fig,ax=plt.subplots()

with open(r'...\vanity 张钰贤.txt') as f:
    text=f.read()

mycloudword=WordCloud(width=800, 
                      height=600, 
                      scale=1, 
                      margin=2,
                      background_color='white',
                      max_words=200, 
                      min_font_size=40, 
                      max_font_size=140,
                      stopwords=STOPWORDS, 
                      random_state=50).generate(text)

ax.imshow(mycloudword)
ax.axis("off")
plt.show()

mycloudword.to_file(r"...\vanity张钰贤.png")



posted @ 2021-04-26 19:32  晓龙我大哥  阅读(170)  评论(0)    收藏  举报