How to force Plotly trendline appear on the top of scatter?

I am drawing a chart with a trendline using Plotly Express:

fig = px.scatter(
    title=f"Best signal per {signal_window_label}",

However, the trendline feature is not very useful as the trendline is hard to see below the scatter:

How can I move the trendline to the top of the chart? I already tried this trick I saw on StackOverflow: =[::-1]

But it only affects the order of the legend box (the trendline is the first in the legend), not the actual visual output.

Plotly 5.18.0

I’m not sure if you can change this.

As far as I know, there is no way to order the traces manually, even though this feature is asked for quite often.

What might help in your case is adding the opacity parameter to your traces.

1 Like

Hi @miohtama !

You should be able to reverse the traces order with =[::-1]
Is it possible to have your full code?
That’s also weird, the trend line should be above by default…