Shared Y in px.histogram

Hi all,

I’m a little confused by the behavior of Especially when coloring by a column. It seems as if the size of the bars doesn’t actually match the Y-axis in some cases. In the first picture below, the blue histogram has a higher value for that bin than the red one but it’s showed above the red one and it’s value doesn’t match the Y-axis. On the second picture the bin of the blue histogram is correctly positioned above the red one. However, its value doesn’t “match” the Y-axis. The code to reproduce the plot is posted at the end.

import as px

election =

fig = px.histogram(election,
                   histnorm="probability density",
                   width=8 * 100,
                   height=5 * 100)

Plotly version 4.8.0, Operative system: Manjaro bspwm

Hi @h4pZ by default the histograms are stacked which is why you see them on top of each other.
If you want them side by side use

1 Like

Hi @RenaudLN,

Thanks for the reply, that makes sense!

Do you know if there is a way to show one histogram in front of each other? Somewhat like in here

Just change it to barmode="overlay".

1 Like

Thank you very much, it works!