您的位置:首页 > 编程语言 > Python开发

Python云图——WordCloud了解一下

2018-06-26 17:04 561 查看

 

字符可以作画(参考前文:使用记事本画出照片)

字符串一样也可以

 

 

安装词云WordCloud.

pip install wordcloud

 

编写要生成词云的内容字符串

 

保存为txt格式就可以了

使用Python代码实现词云

from wordcloud import WordCloud
import matplotlib.pyplot as plt

if __name__ == '__main__':
f = open(u'data.txt','r').read()
word = WordCloud(background_color='white',width=1000,height=860,margin=2).generate(f)
plt.imshow(word)
plt.axis('off')
plt.show()
word.to_file('test.png')

 

效果图:

 

当然这里只是简单的使用了WordCloud的词云功能

他的功能远远不止于此

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: