import plotly.graph_objects as go
from plotly.subplots import make_subplots
fig = make_subplots(rows=2, cols=1, )
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], name="fig1"), row=1, col=1)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], name="yaxis data", yaxis="y2"), row=2, col=1)
fig.add_trace(go.Scatter(x=[2, 3, 4], y=[40, 50, 60], name="yaxis2 data", yaxis="y3"), row=2, col=1)
fig.add_trace(go.Scatter(x=[4, 5, 6], y=[1000, 2000, 3000], name="yaxis3 data", yaxis="y4"),row=2, col=1)
fig.add_trace(go.Scatter(x=[3, 4, 5], y=[400, 500, 600], name="yaxis4 data", yaxis="y5"),row=2, col=1)
fig.update_layout(
xaxis=dict(domain=[0.25, 0.75]),
yaxis2=dict(
title="yaxis title",
autorange="reversed",
anchor="x2",
),
yaxis3=dict(
title="yaxis2 title",
overlaying="y2",
side="right",
),
yaxis4=dict(title="yaxis3 title", anchor="free", overlaying="y", ),
yaxis5=dict(
title="yaxis4 title",
anchor="free",
overlaying="y2",
autoshift=True,
shift=-100,
),
)
fig.update_layout(
title_text="Shifting y-axes by a specific number of pixels",
)
fig.show()
This code is modified from Multiple axes in Python , only with one more row. How to make it work ?