Python pyecharts绘制漏斗图
2021/12/19 11:49:41
本文主要是介绍Python pyecharts绘制漏斗图,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一、pyecharts绘制漏斗图方法简介
funnel.add()方法简介
add(name, attr, value,
funnel_sort="ascending", funnel_gap=0, **kwargs)
name str 图例名称
attr list 属性名称
value list 属性对应的值
funnel_sort str、func
数据排序,可以取ascending,descending,none
funnel_gap int 数据图形间距。默认为0。
二、绘制漏斗图标签显示在内部
attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"] value = [20, 40, 60, 80, 100, 120] funnel = Funnel("漏斗图示例") funnel.add( "商品", attr, value, is_label_show=True, label_pos="inside", label_text_color="#fff", ) page.add(funnel)
三、绘制漏斗图标签显示在外部
#标签显示在外部 funnel2 = Funnel("漏斗图示例", title_pos='center') funnel2.add( "商品", attr, value, is_label_show=True, label_pos="outside", legend_orient="vertical", legend_pos="left", ) page.add(funnel2)
四、数据按升序排列
funnel3 = Funnel("漏斗图示例", title_pos='center') funnel3.add( "商品", attr, value, is_label_show=True, label_pos="inside", legend_orient="vertical", legend_pos="left", funnel_sort="ascending" ) page.add(funnel3)
五、指定图形间隔
funnel4 = Funnel("漏斗图示例", title_pos='center') funnel4.add( "商品", attr, value, is_label_show=True, label_pos="inside", legend_orient="vertical", legend_pos="left", funnel_sort="ascending", funnel_gap=5, ) page.add(funnel4)
六、完整代码如下所示,可直接运行
from pyecharts import Page from pyecharts import Funnel page = Page() #Funnel(漏斗图) ''' funnel.add()方法简介 add(name, attr, value, funnel_sort="ascending", funnel_gap=0, **kwargs) name str 图例名称 attr list 属性名称 value list 属性对应的值 funnel_sort str、func 数据排序,可以取ascending,descending,none funnel_gap int 数据图形间距。默认为0。 ''' #标签显示在内部 attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"] value = [20, 40, 60, 80, 100, 120] funnel = Funnel("漏斗图示例") funnel.add( "商品", attr, value, is_label_show=True, label_pos="inside", label_text_color="#fff", ) page.add(funnel) #标签显示在外部 funnel2 = Funnel("漏斗图示例", title_pos='center') funnel2.add( "商品", attr, value, is_label_show=True, label_pos="outside", legend_orient="vertical", legend_pos="left", ) page.add(funnel2) #数据按升序排列 funnel3 = Funnel("漏斗图示例", title_pos='center') funnel3.add( "商品", attr, value, is_label_show=True, label_pos="inside", legend_orient="vertical", legend_pos="left", funnel_sort="ascending" ) page.add(funnel3) #指定图形间隔 funnel4 = Funnel("漏斗图示例", title_pos='center') funnel4.add( "商品", attr, value, is_label_show=True, label_pos="inside", legend_orient="vertical", legend_pos="left", funnel_sort="ascending", funnel_gap=5, ) page.add(funnel4) page.render()
这篇关于Python pyecharts绘制漏斗图的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-28Python编程基础教程
- 2024-12-27Python编程入门指南
- 2024-12-27Python编程基础
- 2024-12-27Python编程基础教程
- 2024-12-27Python编程基础指南
- 2024-12-24Python编程入门指南
- 2024-12-24Python编程基础入门
- 2024-12-24Python编程基础:变量与数据类型
- 2024-12-23使用python部署一个usdt合约,部署自己的usdt稳定币
- 2024-12-20Python编程入门指南