Bar chart relative + overlay


Is there a way to plot something like this?
The dark blue bars represent the Total value of all the other colored relative stacked bars.

It is a mix between relative barmode and overlay barmode.


Hi, Were you able to achieve it? We need a similar setup.

Try playing with this:

x = [1, 2, 3, 4]

fig = go.Figure()
fig.add_bar(x=x, y=[1, 4, 9, 16], opacity=0.7)
fig.add_bar(x=x, y=[6, -8, -4.5, 8], opacity=0.7)
fig.add_bar(x=x, y=[-15, -3, 4.5, -8], opacity=0.7)
fig.add_bar(x=x, y=[-1, 3, -3, -4], opacity=0.7)

fig.add_bar(x=x, y=[-14, 2, 2, 18], width=[0.5, 0.5, 0.5, 0.5], 
            marker_color='midnightblue', opacity=0.5, base=0)


Actually what would be a great is if the “sum” values would automatically update depending on what traces are selected via the legend.