python用pyecharts画柱状图_小白学Python(13)——pyecharts 绘制 柱状图/条形图 Bar

Bar-基本示例

1 from example.commons importFaker2 from pyecharts importoptions as opts3 from pyecharts.charts importBar4

5 bar=(6 Bar()7 .add_xaxis(Faker.choose())8 .add_yaxis("商家A", Faker.values())9 .add_yaxis("商家B", Faker.values())10 .set_global_opts(title_opts=opts.TitleOpts(title="Bar-基本示例", subtitle="我是副标题"))11 )12

13 bar.render()

1570232-20190822180723365-1370188984.png

翻转 XY 轴

1 from example.commons importFaker2 from pyecharts importoptions as opts3 from pyecharts.charts importBar4

5 bar=(6 Bar()7 .add_xaxis(Faker.choose())8 .add_yaxis("商家A", Faker.values())9 .add_yaxis("商家B", Faker.values())10 .reversal_axis()11 .set_series_opts(label_opts=opts.LabelOpts(position="right"))12 .set_global_opts(title_opts=opts.TitleOpts(title="Bar-翻转 XY 轴"))13 )14

15 bar.render()

1570232-20190822181524270-1120955309.png

Bar-堆叠数据(全部)

1 from example.commons importFaker2 from pyecharts importoptions as opts3 from pyecharts.charts importBar4

5 bar=(6 Bar()7 .add_xaxis(Faker.choose())8 .add_yaxis("商家A", Faker.values(), stack="stack1")9 .add_yaxis("商家B", Faker.values(), stack="stack1")10 .set_series_opts(label_opts=opts.LabelOpts(is_show=False))11 .set_global_opts(title_opts=opts.TitleOpts(title="Bar-堆叠数据(全部)"))12 )13

14 bar.render()

e067227f28f506a12c83c4db50641372e41.png

Bar-MarkPoint(指定类型)

1 from example.commons importFaker2 from pyecharts importoptions as opts3 from pyecharts.charts importBar4

5 bar=(6 Bar()7 .add_xaxis(Faker.choose())8 .add_yaxis("商家A", Faker.values())9 .add_yaxis("商家B", Faker.values())10 .set_global_opts(title_opts=opts.TitleOpts(title="Bar-MarkPoint(指定类型)"))11 .set_series_opts(12 label_opts=opts.LabelOpts(is_show=False),13 markpoint_opts=opts.MarkPointOpts(14 data=[15 opts.MarkPointItem(type_="max", name="最大值"),16 opts.MarkPointItem(type_="min", name="最小值"),17 opts.MarkPointItem(type_="average", name="平均值"),18 ]19 ),20 )21 )22

23 bar.render()

1570232-20190822181826202-1639796607.png

Bar-DataZoom(slider-水平)

1 from example.commons importFaker2 from pyecharts importoptions as opts3 from pyecharts.charts importBar4

5 bar=(6 Bar()7 .add_xaxis(Faker.days_attrs)8 .add_yaxis("商家A", Faker.days_values)9 .set_global_opts(10 title_opts=opts.TitleOpts(title="Bar-DataZoom(slider-水平)"),11 datazoom_opts=opts.DataZoomOpts(),12 )13 )14

15 bar.render()

fa0e427c2a27a7caf265906549063aa4c32.png

Bar-DataZoom(slider-垂直)

1 from example.commons importFaker2 from pyecharts importoptions as opts3 from pyecharts.charts importBar4

5 bar=(6 Bar()7 .add_xaxis(Faker.days_attrs)8 .add_yaxis("商家A", Faker.days_values, color=Faker.rand_color())9 .set_global_opts(10 title_opts=opts.TitleOpts(title="Bar-DataZoom(slider-垂直)"),11 datazoom_opts=opts.DataZoomOpts(orient="vertical"),12 )13 )14

15 bar.render()

e378b75086e28b88ef307ab89c479edf6d4.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值