如何在漏斗图中显示所有数字?

问题描述 投票:0回答:1

但是,我想使用plotly进行漏斗图绘制,但是当我想在框外显示文本时,左侧没有文本,而右侧只有文本。

设置

from plotly import graph_objects as go


stages = ["Homepage visit", "Search page visit",
           "Payment Page", "Payment Confirmation"]

fig = go.Figure()

fig.add_trace(go.Funnel(
    name = 'Desktop',
    y = stages,
    x = [30100, 27090,  2860,   150],
    textposition = "outside",
    textinfo = "value+percent previous"))

fig.add_trace(go.Funnel(
    name = 'Mobile',
    orientation = "h",
    y = stages,
    x = [15100, 12080,  2718,   302],
    textposition = "outside",
    textinfo = "value+percent previous"))

fig.show()

输出

enter image description here

必填

我想查看所有数字。我同时尝试了“内部”和“外部”,但看不到所有数字。

python plotly
1个回答
1
投票

不是,但这是此路径中的内容,请尝试浏览constraintext和文本格式:

from plotly import graph_objects as go


stages = ["Homepage visit", "Search page visit",
           "Payment Page", "Payment Confirmation"]

fig = go.Figure()

fig.add_trace(go.Funnel(
    name = 'Desktop',
    y = stages,
    x = [30100, 27090,  2860,   150],
    textposition = "inside",
    textinfo = "value+percent previous"
    , constraintext='outside'

    ,textfont=dict(
        family="sans serif",
        size=14,
        color="black"
    )

)


             )

fig.add_trace(go.Funnel(
    name = 'Mobile',
    orientation = "h",
    y = stages,
    x = [15100, 12080,  2718,   302],
    textposition = "auto",
    textinfo = "value+percent previous"))

fig.show()
© www.soinside.com 2019 - 2024. All rights reserved.