Reputation: 12107
With these two lines of code:
fig.add_trace(go.Scatter(x=profits['timestamp'], y=profits['balance'], line_color='green'), secondary_y=False, row=2, col=1)
fig.add_trace(go.Scatter(x=events['timestamp'], y=(events['s1_held'] + events['s2_held']), line_color='orange'), secondary_y=True, row=2, col=1)
the line on the secondary_y axis is always drawn on top.
the order of the calls doesn't matter
how can I specify the drawing order?
Upvotes: 1
Views: 851
Reputation: 27370
Traces are drawn per subplot (and the secondary axis counts as a subplot) and make_subplots
draws the secondary above the primary. If you want to change this you will need to create the subplots manually without using make_subplots
as detailed at the bottom of https://plot.ly/python/subplots/
Upvotes: 1