Funnel charts are useful for conversion events or cohort analysis, such as sales cycles.
The following scripts are used in this chapter:
- simple_funnel.py
- stack_funnel.py
- simple_funnelarea.py
This chapter requires the following packages for the scripts used:
- Pandas
- Plotly
This chapter may use the following data from the Data folder:
- ecom_funnel.csv
Data is a list to store either go.Funnel() or go.Funnelarea(). The difference... Please note that x accepts facts or numerics values, while y accepts attribute values or categorical values. Swapping x and y will lead to unexpected behaviour!
go.Funnel() has the following parameters:
- x: The numeric value of the attribute
- y: A categorical value
- name: Category, which will be used for identifying the stacked funnel
- marker: Setting for the funnel bar
- color: The colour of the area of each attribute
- line: The setting for the line
- width
- line
- connector: The setting for the connector between each funnel bar
- line
- color
- dash
- line
- textposition: Text position for y, it can be:
- inside
- outside
- auto
- none
- textinfo: Determines which trace information appear on the graph, it can be:
- text
- value
- current path
- percent root
- percent entry
- percent parent
- Or any combination of them, simply put a + sign between the values above without white space in between
- hoverinfo: What information to be displayed when user hover over the coloured area, all the options are:
- percent
- label+percent
- label
- name
Note: go.Funnelarea() uses value and text! Instead of x and y
go.Funnelarea() has the following parameters:
- value: The numeric value of the attribute
- text: A categorical value (Shown on funnel bars)
- labels: Categorical values (Shown on legend)
- marker: Setting for the funnel bar
- color: The colour of the area of each attribute
- pattern: Setting on how to fill the funnel bars, such as full filled or striped filled
- line: The setting for the line
- width
- line
- connector: The setting for the connector between each funnel bar
- line
- color
- dash
- line
- textposition: Text position for y, it can be:
- inside
- outside
- auto
- none
- textinfo: Determines which trace information appear on the graph, it can be:
- text
- value
- current path
- percent root
- percent entry
- percent parent
- Or any combination of them, simply put a + sign between the values above without white space in between
- hoverinfo: What information to be displayed when user hover over the coloured area, all the options are:
- percent
- label+percent
- label
- name
fig = go.Figure(go.Funnel(
y = df['stage'],
x = df['count'])
)
data = []
for shop in df['shop'].unique():
df_temp = df[df['shop']==shop]
data.append(go.Funnel(
name = shop,
y = df_temp['stage'],
x = df_temp['count'])
)
Use text if you want attribute and values on funnel bars.
fig = go.Figure(go.Funnelarea(
text = df['stage'], # Text displayed on funnel bars
values = df['count'])
)
Use labels if you do not want attribute on funnel bars, but on legned. The values will still stated on funnel bars unless you turn it off.
fig = go.Figure(go.Funnelarea(
labels = df['stage'], # Text displayed only in legend
values = df['count'])
)
Plotly Documentation Funnel Charts



