Python3利用wordcloud实现词云

from wordcloud import WordCloud
import matplotlib.pyplot as plt

#注意这个是没有后缀的
f = open('cloud', 'r').read()
wordcloud = WordCloud(background_color="white", width=1000, height=860, margin=2).generate(f)
plt.imshow(wordcloud)
plt.axis("off")
plt.show()
wordcloud.to_file('example1.png')

上面的cloud文件,因为我是用的ubuntu系统,还不太熟,最后试了一下才发现要不加后缀。

 

最后生成的结果如下。

 

Python3利用wordcloud实现词云

持续更新........