默认词云(英文)

import matplotlib.pyplot as plt
from wordcloud import WordCloud
#步骤一 加载数据文件
file = open('data/constitution.txt',mode='r')
text = file.read()
#步骤二 建立词云对象
wd = WordCloud(background_color='black',max_font_size=40,width=1000,height=600,max_words=20,min_font_size=20)
#自动分词处理
res = wd.generate(text)
#步骤三 显示词云
plt.figure()
#展示词云数据
plt.imshow(res)
#取消x,y轴标
plt.axis('off')
plt.show()
原文地址:https://www.cnblogs.com/zhouqi245776620/p/10191254.html