Cannot create 100% stacked bar in graph object

Hi, I’ve been trying to create a 100% stacked bar from graph object, following this

fig_test = go.Figure()

fig_test.add_trace(go.Bar(
    x = ['A','B'],
    y = [5314, 26591]
))

fig_test.add_trace(go.Bar(
    x = ['A','B'],
    y = [45729, 137985], 
))

fig_test.update_layout(barmode='relative')
fig_test.show()

Result:

How do I get 100% stacked bar from the above sample. Something like the below one? Thanks!

Hello @soapycat99,

One way would be to adjust your y values to be a percentage of the whole, and then put the additional or real values into the hover data section.

3 Likes