可设置的参数参考:https://blog.csdn.net/u010244957/article/details/123729529
data = [
("生活资源", 999),
("供热管理", 888),
("供气质量", 777),
("生活用水管理", 688),]
c = (
WordCloud()
.add(series_name="热词分析", data_pair=data, word_size_range=[5, 50],
# word_gap=20,
mask_image='pl.jpg',
)
.set_global_opts(
title_opts=opts.TitleOpts(
title="热词分析", title_textstyle_opts=opts.TextStyleOpts(font_size=23)
),
# 设置提示框
tooltip_opts=opts.TooltipOpts(is_show=True,
position='right', # 提示框固定在单词右边
formatter=JsCode("function(params){return params.data.articles}"),
# is_always_show_content=True, # 是否一直显示
textstyle_opts=opts.TextStyleOpts(font_size=12)
),
)
)
c.options['series'][0].update({'data':data_list})
c.options['series'][0]['rotationRange'] = [0,90] # 设置旋转区间
c.options['series'][0]['rotationStep'] = 90 # 旋转间隔
c.options['series'][0].update({'gridSize':15}) # 文字间隙
data_list # list-json格式
# name是词
# value是权重
[{‘name’: ‘时尚’,
‘value’: 9.91422964906803,
‘color’: ‘#090d7c’,
‘textStyle’: {‘normal’: {‘color’: ‘#090d7c’}},
‘articles’:‘备注信息,放于提示框’},
{… },
…
]