赞
踩
转自:
[pyecharts学习笔记]——WordCloud词云图 | 码农家园
基本-词云图
注意数据格式 ,[(word1, count1), (word2, count2)] ,可使用 counter 做词频统计,生成这种数据格式
1 | import pyecharts.options as opts |
使用内置-词云图轮廓
词云图轮廓,有 ‘circle’, ‘cardioid’, ‘diamond’, ‘triangle-forward’, ‘triangle’, ‘pentagon’, ‘star’ 可选
一般情况下,推荐自定义的词云轮廓
1 | import pyecharts.options as opts |
自定义图片
1 | # 自定义的图片(目前支持 jpg, jpeg, png, ico 的格式,其他的图片格式待测试) |
这里使用word中的图标制作一个词云轮廓
注:如果使用了 mask_image 之后第一次渲染会出现空白的情况,再刷新一次就可以了
1 | from pyecharts import options as opts |
注:如果使用了 mask_image 之后第一次渲染会出现空白的情况,再刷新一次就可以了
剩下的就是设置一些其他属性
1 | # 单词间隔 |
字体设置
1 | textstyle_opts=opts.TextStyleOpts(font_family="cursive") |
1 | from pyecharts import options as opts |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。