Funnel Charts in Plotly: px.funnel and go.Funnel

Make funnel charts in Plotly with percentages on each stage, compare groups, show step-by-step conversion rates, style the bars and connectors, and use funnel area charts.

Make a funnel chart in Plotly with px.funnel(df, x="count", y="stage"). List the stages in order from first to last, and add percentages with fig.update_traces(textinfo="value+percent initial").

Quick Example

A made-up hiring pipeline:

import pandas as pd
import plotly.express as px

pipeline = pd.DataFrame({
    "stage": ["Applied", "Resume screen", "Phone interview", "Onsite", "Offer", "Hired"],
    "candidates": [1240, 520, 214, 88, 39, 31],
})

fig = px.funnel(pipeline, x="candidates", y="stage", title="Hiring pipeline",
                template="plotly_white", color_discrete_sequence=["#0f766e"],
                labels={"stage": "", "candidates": "Candidates"})
fig.update_traces(textinfo="value+percent initial", textposition="auto")
fig.show()

Plotly funnel chart of a hiring pipeline narrowing from 1,240 applications to 31 hires, with the count and share of applications on each bar

Each percentage is that stage's share of the first stage, so the 88 onsite interviews are 7% of the 1,240 applications. px.funnel keeps the rows in the order you give them and draws the first one at the top. It doesn't sort by size. The code targets Plotly 6.x.

What Do the Percentage Options Mean?

textinfo is any combination of these, joined with +:

Value Shows
"value" The number
"percent initial" Share of the first stage
"percent previous" Share of the stage before it (step conversion)
"percent total" Share of all stages added together
"label" The stage name

"percent total" is rarely what you want in a funnel, since the same people are counted in several stages.

Format the Labels with texttemplate

For full control, use texttemplate. It has the variables %{value}, %{label}, %{percentInitial}, %{percentPrevious} and %{percentTotal}, each of which takes a number format.

fig = px.funnel(pipeline, x="candidates", y="stage", title="Step-by-step conversion",
                template="plotly_white", color_discrete_sequence=["#4338ca"],
                labels={"stage": "", "candidates": "Candidates"})
fig.update_traces(
    texttemplate="%{value:,} ยท %{percentPrevious:.0%} of previous",
    textposition="outside",
)
fig.update_xaxes(range=[-1500, 1500])   # room for the outside labels
fig.show()

Funnel chart with labels outside the bars showing each stage as a percentage of the previous stage

The first stage reads 100%. Offers are accepted far more often (79%) than candidates pass any earlier step, which all sit between 41% and 44%. Funnel bars are centered on zero, which is why the x range is symmetric.

Compare Two Funnels

Pass color to draw one funnel per group. When groups differ a lot in size, plot each stage as a share of that group's first stage so the shapes are comparable:

sources = pd.DataFrame({
    "stage": pipeline["stage"].tolist() * 2,
    "source": ["Referral"] * 6 + ["Job board"] * 6,
    "candidates": [180, 126, 77, 41, 22, 19,
                   1060, 394, 137, 47, 17, 12],
})
sources["share"] = sources["candidates"] / sources.groupby("source")["candidates"].transform("first")

fig = px.funnel(sources, x="share", y="stage", color="source",
                color_discrete_map={"Referral": "#0f766e", "Job board": "#d97706"},
                hover_data={"candidates": True, "share": ":.1%"},
                title="Share of applicants reaching each stage", template="plotly_white",
                labels={"stage": "", "source": "Source"})
fig.update_traces(texttemplate="%{value:.0%}", textposition="auto",
                  connector_visible=False)   # grouped connectors overlap each other
fig.update_layout(funnelmode="group", margin_t=100,
                  legend=dict(orientation="h", yanchor="bottom", y=1.02, x=0))
fig.show()

Funnel chart comparing the share of referral and job board applicants reaching each hiring stage, with referrals higher at every later stage

About 11% of referrals are hired, compared with 1% of job board applicants. With textposition="auto", labels move outside bars that are too narrow to hold them, and the hover label has both the count and the share. The connectors are hidden because they overlap each other in grouped mode.

Stacked Funnels

The default funnelmode stacks the groups, which shows the total and its mix. Percentages from textinfo are calculated within each group, not from the stacked total.

fig = px.funnel(sources, x="candidates", y="stage", color="source",
                color_discrete_map={"Referral": "#0f766e", "Job board": "#d97706"},
                title="All candidates by source", template="plotly_white",
                labels={"stage": "", "source": "Source"})
fig.update_traces(textinfo="value")
fig.show()

Stacked funnel chart where referrals make up a growing share of candidates at later stages

Style the Bars and Connectors with go.Funnel

go.Funnel gives one color per stage, outlines, and control over the shaded connector between bars.

import plotly.graph_objects as go

fig = go.Figure(go.Funnel(
    y=pipeline["stage"], x=pipeline["candidates"],
    marker=dict(color=["#1e3a8a", "#1d4ed8", "#2563eb", "#3b82f6", "#60a5fa", "#f59e0b"]),
    connector=dict(fillcolor="#e2e8f0", line=dict(color="#94a3b8", dash="dot", width=1)),
    textinfo="value", textposition="auto",
    hovertemplate="%{y}<br>%{x:,} candidates<br>%{percentInitial:.1%} of applicants<extra></extra>",
))
fig.update_layout(template="plotly_white", title="Highlight the final stage")
fig.show()

Funnel chart with graded blue bars, an orange final stage and dotted gray connectors

Set connector=dict(visible=False) to remove the shapes between bars.

Vertical Funnel

Swap x and y and set orientation="v" to read the stages from left to right:

fig = px.funnel(pipeline, x="stage", y="candidates", orientation="v",
                title="Pipeline from left to right", template="plotly_white",
                color_discrete_sequence=["#be185d"],
                labels={"stage": "", "candidates": "Candidates"})
fig.update_traces(textinfo="value")
fig.show()

Vertical funnel chart with stages running from left to right

Funnel Area Chart

px.funnel_area takes names and values and draws a tapered shape, similar to a pie chart. The area of each slice is its share of the total of all values, so it suits parts of a whole better than sequential stages.

budget = pd.DataFrame({
    "channel": ["Job boards", "Recruiting events", "Referral bonuses", "Agency fees"],
    "spend": [46, 27, 18, 9],
})

fig = px.funnel_area(budget, names="channel", values="spend",
                     title="Recruiting budget by channel",
                     color_discrete_sequence=["#164e63", "#0e7490", "#06b6d4", "#a5f3fc"])
fig.update_traces(textinfo="label+percent")
fig.update_layout(showlegend=False)
fig.show()

Funnel area chart of recruiting spend, with job boards the largest share at 46 percent

Funnels Side by Side

facet_col splits the data into panels that share the stage axis:

fig = px.funnel(sources, x="candidates", y="stage", facet_col="source",
                title="One panel per source", template="plotly_white",
                color_discrete_sequence=["#475569"],
                labels={"stage": "", "candidates": "Candidates", "source": "Source"})
fig.update_traces(textinfo="value")
fig.update_xaxes(matches=None)   # each panel gets its own scale
fig.show()

Two funnel charts side by side for referral and job board candidates, each on its own scale

With independent scales, the two panels show shape only; their widths can't be compared.

When to Use a Funnel Chart

Funnels suit one sequence where each stage is a subset of the one before: signups, checkout steps, sales pipelines. If stages can grow, or you need readers to compare small differences between groups, use a bar chart, where every bar starts from the same baseline. To show people splitting into different paths, use a Sankey diagram.

If you're comparing conversion between two versions of a page, a funnel shows the drop-off but not whether the difference is real. See A/B test analysis in Python.

Common Problems

  • Stages are in the wrong order. The chart follows row order. Sort the DataFrame, or pass category_orders={"stage": [...]}.
  • Counts come from raw events. Aggregate first, for example df.groupby("stage", sort=False)["user_id"].nunique().
  • Small final stages have unreadable text. Use textposition="outside" and widen the x range.

Similar Topics