Plotly: Create a plot out of subplots, where subplots are overlapping funnels

Here is the dataset (a) I got:

First, i tried to write a code for one chart: 2 overlapping funnels - it worked (please ignore numbers on the chart, they differ from the ones on the dataset (a) )

I tried to write code for four charts and make them subplots - it didn’t work. Can you help me to find out why?:

fig_all = make_subplots(rows=1, cols=4, specs=[[{'type':'domain'}, {'type':'domain'},{'type':'domain'},{'type':'domain'}]])

#web funnel 
trace=go.Funnel(y=a['Source'], x=a['all'],showlegend=False,marker={"color": 'blue'})
trace1=go.Funnel(y=a['Source'], x=a['web'], textposition='outside', marker={"color": 'red'})

fig1 = make_subplots(specs=[[{"secondary_y": True}]])
fig1.add_trace(trace)
fig1.add_trace(trace1, secondary_y=True)

fig1.layout.yaxis.update(showticklabels=False)
fig1.layout.xaxis.update({'visible': True})

fig1.for_each_trace(lambda trace: trace.update(ids=[]) if trace.name == "all" else (),)


#telesales funnel
trace=go.Funnel(y=a['Source'], x=a['all'],showlegend=False,marker={"color": 'blue'})
trace1=go.Funnel(y=a['Source'], x=a['telesales'], textposition='outside', marker={"color": 'red'})

fig2 = make_subplots(specs=[[{"secondary_y": True}]])
fig2.add_trace(trace)
fig2.add_trace(trace1, secondary_y=True)

fig2.layout.yaxis.update(showticklabels=False)
fig2.layout.xaxis.update({'visible': True})

fig2.for_each_trace(lambda trace: trace.update(ids=[]) if trace.name == "all" else (),)


#networking funnel
trace=go.Funnel(y=a['Source'], x=a['all'],showlegend=False,marker={"color": 'blue'})
trace1=go.Funnel(y=a['Source'], x=a['networking'], textposition='outside', marker={"color": 'red'})

fig3 = make_subplots(specs=[[{"secondary_y": True}]])
fig3.add_trace(trace)
fig3.add_trace(trace1, secondary_y=True)

fig3.layout.yaxis.update(showticklabels=False)
fig3.layout.xaxis.update({'visible': True})

fig3.for_each_trace(lambda trace: trace.update(ids=[]) if trace.name == "all" else (),)


#promotions funnel
trace=go.Funnel(y=a['Source'], x=a['all'],showlegend=False,marker={"color": 'blue'})
trace1=go.Funnel(y=a['Source'], x=a['promotion'], textposition='outside', marker={"color": 'red'})

fig4 = make_subplots(specs=[[{"secondary_y": True}]])
fig4.add_trace(trace)
fig4.add_trace(trace1, secondary_y=True)

fig4.layout.yaxis.update(showticklabels=False)
fig4.layout.xaxis.update({'visible': True})

fig4.for_each_trace(lambda trace: trace.update(ids=[]) if trace.name == "all" else (),)


fig_all.add_trace(fig1,1,1)
fig_all.add_trace(fig2,1,2)
fig_all.add_trace(fig3,1,3)
fig_all.add_trace(fig4,1,4)
fig_all.show()

Hi @kdilrabo2911

Not sure if you are still interested in a solution to this question. I am assuming you have solved it already. Nonetheless, I was able to replicate the multiple plots requirement. I took the liberty to change the colours to better understand what is the main objective of this plot.

I am confused as to why you were adding a figure object to another figure object as a trace. Anywho, here’s the code I used:

fig_all = make_subplots(rows=1, cols=4, shared_yaxes = True, horizontal_spacing = 0.002,
                        specs = [[{'type' : 'funnel'},
                                  {'type' : 'funnel'},
                                  {'type' : 'funnel'},
                                  {'type' : 'funnel'}]])
trace = go.Funnel(y = a['Source'],  x=a['all'], showlegend=False, marker={"color": 'lightgrey'}, opacity = 0.8)
trace1 = go.Funnel(y = a['Source'], x=a['web'], textposition='outside', marker={"color": 'red'}, 
                   opacity = 1, name = "Web")

trace2 = go.Funnel(y=a['Source'], x=a['telesales'], textposition='outside', marker={"color": 'green'}, 
                   opacity = 1, name = "Telesales")
trace3 = go.Funnel(y=a['Source'], x=a['networking'], textposition='outside', marker={"color": 'orange'}, 
                   opacity = 1, name = "Networking")
trace4 = go.Funnel(y=a['Source'], x=a['promotion'], textposition='outside', marker={"color": 'cyan'}, 
                   opacity = 1, name = "Promotion")

fig_all.add_trace(trace, row = 1, col = 1)
fig_all.add_trace(trace1, row = 1, col = 1)

fig_all.add_trace(trace, row = 1, col = 2)
fig_all.add_trace(trace2, row = 1, col = 2)

fig_all.add_trace(trace, row = 1, col = 3)
fig_all.add_trace(trace3, row = 1, col = 3)

fig_all.add_trace(trace, row = 1, col = 4)
fig_all.add_trace(trace4, row = 1, col = 4)

fig_all.update_layout(title = "Funnel CHarts in SUbplots Plotly")
fig_all.show()

Here’s what the plot looks like: