Different colours for each facet row in px.bar - how to do it? [Solved]

Hello everyone,

Plotly newbie here. I am trying to create a barplot in which the column facets all have different colours. So far I have succeeded by putting the different categories in the “color” option in px.bar as well as the “facet_col” option. The problem with this is that the plotted bars aren’t aligned, but on different heights. If that doesn’t make any sense, please check the attached file with the barplot I am talking about.

I would like to have all three subplots in different colours AND at the same height. Could anyone please help me with this?


This is the code I am using:

cheng_grafiek=px.bar(cheng.sort_values(by=["Bron","Score"]),y="LAP naam", x="Score", color="Bron", title="Vergelijking scores uit Cheng et al. (2019) en de risico-analyse afval", barmode="group", orientation="h", height=900, facet_col="Bron", #color_discrete_sequence=["blue","magenta","green"], facet_col_spacing=0, category_orders={"Bron": ["Cheng et al. (2019)", "Risico analyse (export)", "Risico analyse (import)"]})

Alright, it was a simple solution. Boy, do I feel like an idiot… All I had to do was change “barmode” to “stack”.

Don’t tell anyone, okay???