Hello,
I want to build a bar chart in which 2 dataseries belong to the first axis, and 2-3 dataseries to the second.
Apply barmode=‘group’ to all data but it only works for data on different axes. Is it possible to somehow apply bar mode=‘group’ to all data on the graph. Of course, you can use invisible axes, but I have a lot of data and it’s tedious…
import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Bar(
x=[10, 20, 30],
y=[200, 450, 700],
name="yaxis1 values",
yaxis="y",
offsetgroup=1,
))
fig.add_trace(go.Bar(
x=[10, 20, 30],
y=[900, 350, 560],
name="yaxis3 values",
yaxis="y",
offsetgroup=1,
))
fig.add_trace(go.Bar(
x=[10, 20, 30],
y=[2000, 5000, 7000],
name="yaxis4 values",
yaxis="y2",
offsetgroup=2,
))
fig.update_layout(
xaxis=dict(
domain=[0, 0.7]
),
yaxis=dict(
title="yaxis 1",
),
yaxis2=dict(
title="yaxis 2",
anchor="x",
overlaying="y",
side="right"
),
barmode='group',
)