python绘制漏斗图步骤详解
作者:laozhang 时间:2021-06-17 22:57:57
pyecharts中的Funnel函数可以绘制漏斗图,自动根据数据大小生成由大到小自上而下排列的一个漏斗样的图形。
1、导入Funnel模块。
from pyecharts import Funnel
2、初始化图形参数。
funnel = Funnel("漏斗图", width=600, height=400, title_pos='center')
3、输入数据并绘图。
funnel.add("商品交易行为记录数据", ['浏览','加入购物车','下单','支付','交易成功'], [40000,18000,10000,8500,8000], is_label_show=True,label_formatter='{b} {c}',label_pos="outside",legend_orient='vertical', legend_pos='left')
这里legend_orient、legend_pos分别表示图例的方向和位置,label_formatter为数据标签显示格式,{a}展示系列名称,{b}展示数据项名称,{c}展示数据项数值, {d}展示数值百分比。
4、保存并查看图形。
funnel.render()
5、显示百分比。
funnel = Funnel("整体转化率", "图中的比例表示该行为下的用户数占总用户数(6万)的比例",width=600, height=400, title_pos='center')
funnel.add("商品交易行为记录数据", ['浏览','加入购物车','下单','支付','交易成功'], [int(100*i/60000) for i in [40000,18000,10000,8500,8000]], is_label_show=True,label_formatter='{b} {c}%',label_pos="outside",
legend_orient='vertical', legend_pos='left')
注意:这里百分比做了一些处理。而单独用{d}展示意义不一样。
6、保存并展示数据。
funnel.render(‘data.html')
标签:python,漏斗图
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
PHP连接和操作MySQL数据库基础教程
2023-11-20 22:41:47
编写安全的SQL Server扩展存储过程
2008-11-25 11:16:00
加密处理使密码更安全[CFS编码加密]
2008-03-19 13:30:00
Pygame实战练习之保护单身狗游戏
2022-07-04 03:30:28
![](https://img.aspxhome.com/file/2023/5/94135_0s.gif)
分享Pytest fixture参数传递的几种方式
2023-06-15 01:25:28
python数据可视化之条形图画法
2021-08-07 13:43:22
![](https://img.aspxhome.com/file/2023/6/98966_0s.jpg)
Python使用pyautocad+openpyxl处理cad文件示例
2022-05-24 11:44:18
可刷新的Div+CSS+JS二级下拉树型菜单
2007-10-09 19:14:00
python测试开发django之使用supervisord 后台启动celery 服务(worker/beat)
2023-10-14 05:55:53
python学习必备知识汇总
2022-01-05 10:26:23
Python中使用Frozenset对象的案例详解
2023-09-27 09:36:32
js数组与字符串的相互转换方法
2023-06-24 09:41:48
Python数学建模学习模拟退火算法多变量函数优化示例解析
2021-05-07 09:36:37
扫盲大讲堂:mysql出错的代码解析及解答
2009-09-05 10:08:00
一步步教你用Python实现2048小游戏
2023-02-15 20:51:29
![](https://img.aspxhome.com/file/2023/9/82809_0s.jpg)
python opencv之SIFT算法示例
2023-12-27 21:42:33
![](https://img.aspxhome.com/file/2023/0/65950_0s.png)
Python赋值逻辑的实现
2023-09-14 21:20:27
![](https://img.aspxhome.com/file/2023/1/97251_0s.png)
Python爬取成语接龙类网站
2022-04-09 07:29:58
![](https://img.aspxhome.com/file/2023/5/87795_0s.png)
python tkinter实现弹窗的输入输出
2021-10-03 14:58:42
![](https://img.aspxhome.com/file/2023/3/71453_0s.jpg)
PHP中str_split()函数的用法讲解
2023-06-05 09:43:15
![](https://img.aspxhome.com/file/2023/5/55375_0s.png)