python echarts_python下的echarts

记录

首先pip install pyecharts

代码

from pyecharts import Bar

from pyecharts import Pie

from pyecharts.engine import create_default_environment

from pyecharts.utils import write_utf8_html_file

def report_form():

attr=["衬衫","羊毛衫","雪纺衫"]

v1=[5,20,36]##数量

v2=[10,12,28]

##bar

bar=Bar("bar图表")

bar.use_theme("macarons")##主题

bar.add(

"商家A",attr,v1,

is_splitline_show=False,##不显区域分隔线

is_label_show=True ##显示数据

)

bar.add("商家B",attr,v2,

is_splitline_show=False,

is_label_show=True

)

##pie

pie=Pie("饼图",title_pos='center',width=1000)

pie.use_theme("macarons")

pie.add("",attr,v1,center=[25,60],

radius=[30,70],

rosetype="radius", ##是否展示成南丁格尔图

legend_pos='left', ##图例位置

legend_orient='vertical', ##图例列表的布局朝向

is_label_show=True)

pie.add("",attr,v2,center=[75,60],

radius=[30,70],

rosetype="radius",

legend_pos='left',

legend_orient='vertical',

is_label_show=True)

##bar

env = create_default_environment("html")

env.render_chart_to_file(bar, path='bar.html')

##pie

env = create_default_environment("html")

env.render_chart_to_file(pie, path='pie.html')

report_form()

运行会生成bar.html,pie.html两个文件到代码文件当前目录,打开就是相应的表。

如果打开显示数据是空白的,装一下主题pip install echarts-themes-pypkg

图;

bar

9572e41578415edef1726177b4d0318471a.jpg

pie

666954fb2ab0e3cc1d1c8f372236a33766b.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值