Several Stacked Bar Charts per index

Hello lovely people :slight_smile:

Is there a way to generate a multi stacked bar charts figure in plotly such as the following image:

the following is a list of 3 figures that generate stacked bar charts, each corresponding to a certain date.

  • the x axes represents age.
  • the bar stacked bar charts represent the percentage of each of 3 categories (intent, no, unaware)
  • all 3 figures have the same x axis.

[Figure({
β€˜data’: [{β€˜name’: β€˜2021.03.20 R_UNAWARE’,
β€˜type’: β€˜bar’,
β€˜x’: array([β€˜25-34’, β€˜<25’, β€˜55+’, β€˜45-54’, β€˜35-44’], dtype=object),
β€˜y’: array([Decimal(β€˜0.4523800000’), Decimal(β€˜0.5781250000’),
Decimal(β€˜0.5277770000’), Decimal(β€˜0.4482750000’),
Decimal(β€˜0.4687500000’)], dtype=object)},
{β€˜name’: β€˜2021.03.20 R_NO’,
β€˜type’: β€˜bar’,
β€˜x’: array([β€˜25-34’, β€˜<25’, β€˜55+’, β€˜45-54’, β€˜35-44’], dtype=object),
β€˜y’: array([Decimal(β€˜0.0952380000’), Decimal(β€˜0.3437500000’),
Decimal(β€˜0.1388880000’), Decimal(β€˜0.0689650000’),
Decimal(β€˜0.0937500000’)], dtype=object)},
{β€˜name’: β€˜2021.03.20 R_INTENT’,
β€˜type’: β€˜bar’,
β€˜x’: array([β€˜25-34’, β€˜<25’, β€˜55+’, β€˜45-54’, β€˜35-44’], dtype=object),
β€˜y’: array([Decimal(β€˜0.4523800000’), Decimal(β€˜0.0781250000’),
Decimal(β€˜0.3333330000’), Decimal(β€˜0.4827580000’),
Decimal(β€˜0.4375000000’)], dtype=object)}],
β€˜layout’: {β€˜barmode’: β€˜stack’, β€˜template’: β€˜β€¦β€™}
}),
Figure({
β€˜data’: [{β€˜name’: β€˜2021.04.14 R_UNAWARE’,
β€˜type’: β€˜bar’,
β€˜x’: array([β€˜55+’, β€˜25-34’, β€˜45-54’, β€˜35-44’, β€˜<25’], dtype=object),
β€˜y’: array([Decimal(β€˜0.4838700000’), Decimal(β€˜0.4761900000’),
Decimal(β€˜0.3043470000’), Decimal(β€˜0.1000000000’),
Decimal(β€˜0.6818180000’)], dtype=object)},
{β€˜name’: β€˜2021.04.14 R_NO’,
β€˜type’: β€˜bar’,
β€˜x’: array([β€˜55+’, β€˜25-34’, β€˜45-54’, β€˜35-44’, β€˜<25’], dtype=object),
β€˜y’: array([Decimal(β€˜0.2580640000’), Decimal(β€˜0E-10’), Decimal(β€˜0E-10’),
Decimal(β€˜0.0666660000’), Decimal(β€˜0.1363630000’)], dtype=object)},
{β€˜name’: β€˜2021.04.14 R_INTENT’,
β€˜type’: β€˜bar’,
β€˜x’: array([β€˜55+’, β€˜25-34’, β€˜45-54’, β€˜35-44’, β€˜<25’], dtype=object),
β€˜y’: array([Decimal(β€˜0.2580640000’), Decimal(β€˜0.5238090000’),
Decimal(β€˜0.6956520000’), Decimal(β€˜0.8333330000’),
Decimal(β€˜0.1818180000’)], dtype=object)}],
β€˜layout’: {β€˜barmode’: β€˜stack’, β€˜template’: β€˜β€¦β€™}
}),
Figure({
β€˜data’: [{β€˜name’: β€˜2021.04.29 R_UNAWARE’,
β€˜type’: β€˜bar’,
β€˜x’: array([’<25’, β€˜25-34’, β€˜55+’, β€˜45-54’, β€˜35-44’], dtype=object),
β€˜y’: array([Decimal(β€˜0.4705880000’), Decimal(β€˜0.4444440000’),
Decimal(β€˜0.2051280000’), Decimal(β€˜0.1500000000’),
Decimal(β€˜0.3548380000’)], dtype=object)},
{β€˜name’: β€˜2021.04.29 R_NO’,
β€˜type’: β€˜bar’,
β€˜x’: array([’<25’, β€˜25-34’, β€˜55+’, β€˜45-54’, β€˜35-44’], dtype=object),
β€˜y’: array([Decimal(β€˜0.4705880000’), Decimal(β€˜0.1481480000’),
Decimal(β€˜0.4871790000’), Decimal(β€˜0E-10’), Decimal(β€˜0.0645160000’)],
dtype=object)},
{β€˜name’: β€˜2021.04.29 R_INTENT’,
β€˜type’: β€˜bar’,
β€˜x’: array([’<25’, β€˜25-34’, β€˜55+’, β€˜45-54’, β€˜35-44’], dtype=object),
β€˜y’: array([Decimal(β€˜0.0588230000’), Decimal(β€˜0.4074070000’),
Decimal(β€˜0.3076920000’), Decimal(β€˜0.8500000000’),
Decimal(β€˜0.5806450000’)], dtype=object)}],
β€˜layout’: {β€˜barmode’: β€˜stack’, β€˜template’: β€˜β€¦β€™}
}),
Figure({
β€˜data’: [{β€˜name’: β€˜2021.05.06 R_UNAWARE’,
β€˜type’: β€˜bar’,
β€˜x’: array([β€˜25-34’, β€˜55+’, β€˜45-54’, β€˜<25’, β€˜35-44’], dtype=object),
β€˜y’: array([Decimal(β€˜0.2500000000’), Decimal(β€˜0.1290320000’),
Decimal(β€˜0.0909090000’), Decimal(β€˜0.5000000000’),
Decimal(β€˜0.2325580000’)], dtype=object)},
{β€˜name’: β€˜2021.05.06 R_NO’,
β€˜type’: β€˜bar’,
β€˜x’: array([β€˜25-34’, β€˜55+’, β€˜45-54’, β€˜<25’, β€˜35-44’], dtype=object),
β€˜y’: array([Decimal(β€˜0.0750000000’), Decimal(β€˜0.5161290000’), Decimal(β€˜0E-10’),
Decimal(β€˜0.1818180000’), Decimal(β€˜0.0697670000’)], dtype=object)},
{β€˜name’: β€˜2021.05.06 R_INTENT’,
β€˜type’: β€˜bar’,
β€˜x’: array([β€˜25-34’, β€˜55+’, β€˜45-54’, β€˜<25’, β€˜35-44’], dtype=object),
β€˜y’: array([Decimal(β€˜0.6750000000’), Decimal(β€˜0.3548380000’),
Decimal(β€˜0.9090900000’), Decimal(β€˜0.3181810000’),
Decimal(β€˜0.6976740000’)], dtype=object)}],
β€˜layout’: {β€˜barmode’: β€˜stack’, β€˜template’: β€˜β€¦β€™}
})]

I would like to combine these 3 figures into one.

Thanks in advance :v:

Hi @nadros,

Welcome to the community! :slightly_smiling_face:

I am not sure that you can do it easily (or at all) using two x axis. My suggestion would be to go with a subplot/facet approach, as demonstrated here:

You can have titles to replace each age group β€œindex”, so each subplot would have 3 stacked bars.

Would something like this work for you?