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 plotly.express 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 = px.bar(df, x='DateTime', y=['A','B'],title="Stacked barchart 100%",barmode='relative')
fig.update_layout(legend_title="Legende")
fig.show()

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: