I am trying to add a trace to a subplot that was not created with make_subplots
, but rather with the low-level api documented at the bottom of this page. However, using add_trace
does not work because the subplots were not created with make_subplot
, as documented here.
Is it at all possible to add a trace to a subplot if it was not created with make_subplots
?
trace1 = go.Scatter(
x=[1, 2, 3],
y=[4, 5, 6]
)
trace2 = go.Scatter(
x=[20, 30, 40],
y=[50, 60, 70],
xaxis="x2",
yaxis="y2"
)
data = [trace1, trace2]
layout = go.Layout(
xaxis=dict(
domain=[0, 0.7]
),
xaxis2=dict(
domain=[0.8, 1]
),
yaxis2=dict(
anchor="x2"
)
)
fig = go.Figure(data=data, layout=layout)
fig.show()