Iād like to add error bars in grouped bar chart (actually a histogram), something like this:
The source data are melted, so I cannot add individual traces and specify their errors.
Is there a way how to achieve that?
My data look something like this:
pd.DataFrame({"name":["foo", "bar"]*2, "x":["A", "A", "B", "B"], "y":[5, 6, 7, 8]})
Thanks!
So I found the solution.
- Use bar plot instead of histogram (histogram does not have error_y argument).
- Simply set error_y argument to an array-like of error values, e. g.
figure = px.bar(
dataframe,
x="name",
y="y",
color='x',
barmode='group',
error_y=[6, 7, 5, 6, 7, 7]
Works well for melted data too, you just need to pass list with equal number of elements as there are bars in your graph. Easy