pyecharts_WordCloud

全部来自于官方文档,主要用于方便自己查找

WordCloud:词云图

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from pyecharts.charts import WordCloud
import pyecharts.options as opts
word = [ ("花鸟市场", 1446),
("汽车", 928),
...
]
c = (WordCloud()
.add(series_name='',
data_pair=word,
word_size_range=[],
mask_image='',
textstyle_opts = opts.TextStyleOpts(font_family='cursive')
)
.set_global_opts(title_opts=opts.TitleOpts(title='主标题'))
.render('xxx.html')
)
  • .add()
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    def add(
    # 系列名称,用于 tooltip 的显示,legend 的图例筛选。
    series_name: str,

    # 系列数据项,[(word1, count1), (word2, count2)]
    data_pair: Sequence,

    # 词云图轮廓,有 'circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star' 可选
    shape: str = "circle",

    # 自定义的图片(目前支持 jpg, jpeg, png, ico 的格式,其他的图片格式待测试)
    # 该参数支持:
    # 1、 base64 (需要补充 data 头);
    # 2、本地文件路径(相对或者绝对路径都可以)
    # 注:如果使用了 mask_image 之后第一次渲染会出现空白的情况,再刷新一次就可以了(Echarts 的问题)
    # Echarts Issue: https://github.com/ecomfe/echarts-wordcloud/issues/74
    mask_image: types.Optional[str] = None,

    # 单词间隔
    word_gap: Numeric = 20,

    # 单词字体大小范围
    word_size_range=None,

    # 旋转单词角度
    rotate_step: Numeric = 45,

    # 距离左侧的距离
    pos_left: types.Optional[str] = None,

    # 距离顶部的距离
    pos_top: types.Optional[str] = None,

    # 距离右侧的距离
    pos_right: types.Optional[str] = None,

    # 距离底部的距离
    pos_bottom: types.Optional[str] = None,

    # 词云图的宽度
    width: types.Optional[str] = None,

    # 词云图的高度
    height: types.Optional[str] = None,

    # 允许词云图的数据展示在画布范围之外
    is_draw_out_of_bound: bool = False,

    # 提示框组件配置项,参考 `series_options.TooltipOpts`
    tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,

    # 词云图文字的配置
    textstyle_opts: types.TextStyle = None,

    # 词云图文字阴影的范围
    emphasis_shadow_blur: types.Optional[types.Numeric] = None,

    # 词云图文字阴影的颜色
    emphasis_shadow_color: types.Optional[str] = None,
    )