本文中介绍了几种常见的利用 plotly_express 作图方法的参数
In a scatter plot, each row of data_frame is represented by a symbol mark in 2D space.
In a 2D line plot, each row of data_frame is represented as vertex of a polyline mark in 2D space.
In a polar line plot, each row of data_frame is represented as vertex of a polyline mark in polar coordinates.
In a stacked area plot, each row of data_frame is represented as vertex of a polyline mark in 2D space. The area between successive polylines is filled.
在堆叠的面积图形中,每行的DF数据代表多边形的最高点。
In a bar plot, each row of data_frame is represented as a rectangular mark.
在柱状图中,每行的DF数据代表一个矩形
In a polar bar plot, each row of data_frame is represented as a wedge(楔形) mark in polar coordinates.
In a violin plot, rows of data_frame are grouped together into a curved(弯曲的) mark to visualize their distribution(分布)
In a histogram, rows of data_frame are grouped together into a rectangular mark to visualize the 1D distribution of an aggregate function histfunc (e.g. the count or sum) of the value y (or x if orientation is 'h').
In a pie plot, each row of data_frame is represented as a sector of a pie
In a choropleth map, each row of data_frame is represented by a colored region mark on a map.
通常在地图中使用
In a density heatmap, rows of data_frame are grouped together into colored rectangular tiles to visualize the 2D distribution of an aggregate function histfunc (e.g. the count or sum) of the value z.
参数解释以第一个散点图为例:
其他作图方法的作图参数类似
本文主要针对plotly的参数含义进行说明,随着plotly版本的迭代更新,部分参数的用法会有细微变化,具体参加 官方文档
漏斗图是销售领域一种十分常用的图表,主要是用来分析在各个阶段的流失和转化情况。比如在某个商城中,我们统计用户在不同阶段的人数来分析转化率:
从搜索人数开始到支付成功,每个阶段用户都存在一定的流失,漏斗图就能很好地将这种流失和转化情况显示出来。
除去柱状图、饼图、折线图,漏斗图应该是自己在工作画的最为频繁的一种图表。下面我们通过模拟某个电商网站的用户行为来绘制漏斗图。
基于两种方式实现:
模拟一份商城数据:
绘制一个基础漏斗图:
我们还可以加上一个颜色参数color:
如果我们的颜色设置成number列,用数值意义似乎不准确,更好地应该是不同的阶段表示,换成stage:
看生成的漏斗图:最上面的是支付成功,通常我们希望的是数值最大的在最上面,于是我们 将传入的数据 翻转一下:
分组漏斗表示的含义将不同组别的漏斗图放在一个画布中,比如: 看今年3月和2020年3月的数据对比情况 ,这叫做同比
1、2020年3月份数据
2、2021年3月份数据
3、使用concat函数合并两组数据
4、绘制漏斗图
还是使用最上面的数据:
我们观察到: 面积漏斗图默认绘制的百分比,而普通漏斗图是数值
我们需要主题textinfo参数的使用,它有3种使用方式:
上面这个漏斗图使用的是percent initial(相对于初始值),百分比是这样来的:
如果是percent previous:
如果是percent total:
我们看看第一个百分比是如何计算的:
在上面的图中,既可以观察到同比情况(2020年3月和2021年3月),也可以观察到环比情况(2021年3月和2月)
不同组别的漏斗图我们也可以分开放,将它们放在一个大的画布中:
漏斗图真的很好用,能够观察到数据在不同阶段的转化情况。毕竟领导每个月都要看一下