I have a figure that gets created like this:
import plotly.graph_objects as go
fig_init = go.Figure(data=[
go.Bar(name='Bla1', x=df.x, y=df.y1), #
go.Bar(name='Bla2', x=df.x, y=df.y2),
])
fig_init.show()
Now I would actually like to make this figure a subplot. I figured out I could do this:
fig2 = make_subplots(rows=1, cols=1)
fig2.add_trace(
go.Bar(name='Bla1', x=df.x, y=df.y1),
row=1, col=1
)
fig2.add_trace(
go.Bar(name='Bla2', x=df.x, y=df.y2),
row=1, col=1
)
But I wonder is there a shorter way/code to put the 2 bar plots into a single subplot? This would be useful, because I actually aim to put 4 bar plots into a single subplot. E.g. Is something like this possible?
fig2 = make_subplots(rows=1, cols=1)
fig2.add_trace(
data=[fig_init.data[0]],
row=1, col=1
)
but without losing the formatting and layout of fig_init
?