本文主要是介绍plotly怎么绘制漏斗图?,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、案例一
trace = go.Funnel(y = ["注册", "实名认证", "绑卡", "合格投资者", "投资", "复投"],x = [220, 180, 160, 80, 40, 20],textinfo = "value+percent initial",marker=dict(color=["deepskyblue", "lightsalmon", "tan", "teal", "silver", "yellow"]),connector = {"line": {"color": "royalblue", "dash": "solid", "width": 3}})data =[trace]fig = go.Figure(data)fig.show()
结果如下:
2、案例二:绘制不同网站的对比转化率漏斗图
import plotly.express as px
import pandas as pddf = pd.read_excel("funnel.xlsx")
display(df)
fig = px.funnel(df, x='数值', y='状态', color='网站')
fig.show()df1 = df[df["网站"] == "A"]
df2 = df[df["网站"] == "B"]fig = go.Figure()trace0 = go.Funnel(x = df1["数值"],y = df1["状态"],name = 'A网站',textinfo = "value+percent initial",marker=dict(color=["red"]*5),connector = {"line": {"color": "lightsalmon", "dash": "solid", "width": 3}},opacity=0.49)trace1 = go.Funnel(x = df2["数值"],y = df2["状态"],name = 'B网站',textinfo = "value+percent previous",orientation = "h",marker=dict(color=["deepskyblue"]*5),connector = {"line": {"color": "lightsalmon", "dash": "solid", "width": 3}})fig.add_trace(trace0)
fig.add_trace(trace1)fig.show()
结果如下:
这篇关于plotly怎么绘制漏斗图?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!