【解】pip安装pyecharts后报错 failed to import pyecharts_snapshot

问题:pip3 intall pyecharts后显示failed to import pyecharts_snapshot

解决方法:
pip3 install pyecharts-snapshot

简单使用:

Bar.add() 方法签名

add(name, x_axis, y_axis,
    is_stack=False,
    bar_category_gap='20%', **kwargs)
  • name -> st
    图例名称
  • x_axis -> list
    x 坐标轴数据
  • y_axis -> list
    y 坐标轴数据
  • is_stack -> bool
    数据堆叠,同个类目轴上系列配置相同的 stack 值可以堆叠放置
  • bar_category_gap -> int/str
    类目轴的柱状距离,当设置为 0 时柱状是紧挨着(直方图类型),默认为 ‘20%’

举例:

dataZoom 效果,‘slider’ 类型

from pyecharts import Bar
t_index = train_all['class'].value_counts(ascending = True).index
t_value = train_all['class'].value_counts(ascending = True).values

bar = Bar('大标题','小标题')
bar.use_theme('dark') #暗色背景色
bar.add('class',t_index,t_value,)
bar

                                 
bar.add('label',    
        ['L','G','B','T','Q'],#横坐标index
        [10, 10, 10, 10, 10],#纵坐标value
        is_label_show = True, 
        is_datazoom_show = True)
bar.render('./bar.html')#文件存储路径(默认保存当前文件路径)

具体参考:
https://github.com/pyecharts/pyecharts/blob/5c26a1dd01a4b311e1cc21e00c9072e2c6189ff7/docs/zh-cn/charts.md

猜你喜欢

转载自blog.csdn.net/weixin_42317507/article/details/89146432