最近新开了一门数据可视化的课程 所以来更新一下有关词云图的学习
词云图范例1
from pyecharts import options as opts
from pyecharts.charts import Page, WordCloud
from pyecharts.globals import SymbolType
words = [
("手中雕刻生花", 10000),
("刀锋千转蜿蜒成画", 6181),
("盛名功德塔", 4386),
("是桥畔某处人家", 4055),
("春风绕过发梢红纱", 2467),
("刺绣赠他", 2244),
("眉目刚烈拟作妆嫁", 1868),
("轰烈流沙枕上白发", 1484),
("杯中酒比划", 1112),
("年少风雅鲜衣怒马", 865),
("也不过一刹那", 847),
("难免疏漏儿时檐下", 582),
("莫测变化", 555),
("隔却山海", 550),
("转身从容煎茶", 462),
]
worldcloud=(
WordCloud()
.add("", words, word_size_range=[20, 150])
.set_global_opts(title_opts=opts.TitleOpts(title="WordCloud-基本示例"))
)
worldcloud.render('C:\Users\Administrator\Desktop\代码\歌词词云图.html')
词云图范例2
from pyecharts.charts import WordCloud
name = ['云想衣裳花想容','春风拂槛露华浓','若非群玉山头见','会向瑶台月下逢','一枝秾艳露凝香','云雨巫山枉断肠',
'借问汉宫谁得似','可怜飞燕倚新妆','名花倾国两相欢','长得君王带笑看','解释春风无限恨','沈香亭北倚阑干']
value = [945,760,389,209,250,450,850,560,780,150]
data = list(zip(name, value))
mywordcloud = WordCloud()
mywordcloud.add('',data, shape = 'triangle')
### 渲染图片
mywordcloud.render('C:\Users\Administrator\Desktop\代码\诗词词云图.html') # render ---提交
### 指定渲染图片存放的路径
词云图范例3
from pyecharts.charts import WordCloud
data_E = [('Hello',23),('My',25),('Name',50),('is',5),('xxx',80)]
#这里可以写自己的名字
mywordcloud_E = WordCloud()
mywordcloud_E.add('',data_E, shape = 'circle')
### 渲染图片
mywordcloud_E.render('C:\Users\Administrator\Desktop\代码\有趣的词云图.html') # render ---提交
### 指定渲染图片存放的路径