Hello,
is it possible to update layout axes in a loop for?
I would like to update axis when adding trac
import plotly.graph_objects as go
def my_bar(my_fig,x_value, y_value,_offestgroup,_yaxis):
my_fig.add_trace(go.Bar(
x=x_value,
y=y_value,
name=_yaxis,
offsetgroup=_offestgroup,
yaxis=_yaxis
))
d = {'x': [10, 20, 30], 'y': [200, 450, 700],
'y2': [900, 350, 560],
'y3': [9000, 5000, 7000],
}
list_offsetgroup={
'y': 1,
'y2': 2,
'y3':3
}
fig = go.Figure()
list_yaxis=['y','y2','y3']
for my_yaxis in list_yaxis:
my_bar(fig, d['x'] , d[my_yaxis],list_offsetgroup[my_yaxis] ,my_yaxis)
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"
),
yaxis3=dict(
overlaying="y",
visible=False,
),
barmode='group',
)