Thomas
Thomas

Reputation: 12107

line order with plotly

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

Answers (1)

nicolaskruchten
nicolaskruchten

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

Related Questions