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

**URL:** <https://community.plotly.com/t/how-to-force-plotly-trendline-appear-on-the-top-of-scatter/80375>\
**Category:** 📊 Plotly Python\
**Created:** [November 24, 2023, 7:39pm UTC](https://community.plotly.com/t/how-to-force-plotly-trendline-appear-on-the-top-of-scatter/80375 "2023-11-24T19:39:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![miohtama](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/miohtama/32/19517_2.png) [@miohtama](https://community.plotly.com/u/miohtama)\
**Post date:** [November 24, 2023, 7:39pm UTC](https://community.plotly.com/t/how-to-force-plotly-trendline-appear-on-the-top-of-scatter/80375/1 "2023-11-24T19:39:34Z")

</div>

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

```python
fig = px.scatter(
    max_df, 
    x="signal", 
    y="profit", 
    trendline="lowess",
    title=f"Best signal per {signal_window_label}",
    trendline_color_override="black",
    trendline_scope="overall",
    color="pair_id",
)

```

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

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/5/9/59b025fb2c9f6ec3b10a4ffb95a69c17c043d4d2.png)

How can I move the trendline to the top of the chart? I already tried this trick I saw on StackOverflow:

```python
fig.data = fig.data[::-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

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [November 24, 2023, 8:16pm UTC](https://community.plotly.com/t/how-to-force-plotly-trendline-appear-on-the-top-of-scatter/80375/2 "2023-11-24T20:16:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Skiks](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/skiks/32/26561_2.png) [@Skiks](https://community.plotly.com/u/Skiks)\
**Post date:** [November 25, 2023, 10:10am UTC](https://community.plotly.com/t/how-to-force-plotly-trendline-appear-on-the-top-of-scatter/80375/3 "2023-11-25T10:10:17Z")

</div>

Hi @miohtama !

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