Plotly express :100% stacked barchart

I’m trying to make a 100% stacked barchart.
Is this possible in plotly or should I adapt the dataframe?

import pandas as pd
import as px
df = pd.DataFrame({"DateTime": pd.date_range(start="2022-01-01", end="2022-01-10")})
df["A"] = np.random.randint(0, 10, size=len(df))
df["B"] = np.random.randint(0, 5, size=len(df))
fig =, x='DateTime', y=['A','B'],title="Stacked barchart 100%",barmode='relative')

Hi, a far as I know there is no built in functionality for this. We had a similar topic a while ago but I can’t find it right now…

Hello @marvy,

The easiest and most straightforward way would be to adjust the dataframe. :slight_smile: