I have see code that nicely places bar charts infront of area charts using overlaying. But how can I create this in a sub_plot scenario?
Specifically I try to move the Scatter area behind the bars in this sub_plot:
from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(rows=1, cols=2)
fig.add_trace(
go.Scatter(x=[1, 2, 3], y=[4, 5, 6],
mode=โlinesโ,
fill=โtonextyโ,
yaxis=โy1โ,),
row=1, col=1
)
fig.add_trace(
go.Bar(x=[1, 2, 3], y=[4, 5, 6],
yaxis=โy2โ,),
row=1, col=1
)
fig.add_trace(
go.Scatter(x=[20, 30, 40], y=[50, 60, 70],
mode=โlinesโ,
fill=โtonextyโ,
yaxis=โy3โ,),
row=1, col=2
)
fig.add_trace(
go.Bar(x=[20, 30, 40], y=[50, 60, 70],
yaxis=โy4โ,),
row=1, col=2
)
fig.update_layout(height=600, width=800,
title_text=โSide By Side Subplotsโ,
yaxis1=dict(overlaying=โy2โ),
yaxis3=dict(overlaying=โy4โ))
fig.show()