Black Lives Matter. Please consider donating to Black Girls Code today.

Scatter - fill overlaps the traces


I have a plot with two traces (both scatter)
trace1 is in y=y
trace 2 is in y=y2 and has a fill up to the x axis.

the problem is that the fill of trace 2 overlaps the trace 1.

How can I “send back” the trace 2 so that trace 1 is always over trace 2


simply reverse their order in your call to Plotly.newPlot() like this:
Plotly.newPlot(myDiv, [trace2, trace1], layout);

If you don’t specify a fillcolor in your trace, it might be confusing because by default the first trace is blue, and the second one is orange. So it might have looked like the orange graph is always on top of blue, because it is.