Change trace order in parallel plots with plotly

I have a question about plotly parallel_coordinates function.

To reproduce my case use this code:

import numpy as np
import pandas as pd
import as px

data = np.random.random([1000,2])
data_df = pd.DataFrame(data, columns=["data1","data2"])
fig_parallel = px.parallel_coordinates(data_df,

You will get this image: enter image description here

The color-bar correspond to the last axis ( data2).

We can notice that the traces going to the top of the last axis (the yellow ones) are in front of the plot.

What I want to have is the same plot but with the blue traces in the front of the image to have a better visualisation (bottom data are my data of interest).

Thank you in advance to any one who may be able to give me a solution ^^

Welcome to the community!

I didnโ€™t find a solution that simple changes which traces are in the front and which are in the back. But there might be another option - by setting a constraintrange on the go.Parcoords, you can limit which lines are initially displayed.

Your new code would look like this:

import numpy as np
import pandas as pd
import plotly.graph_objects as go

data = np.random.random([1000, 2])
data_df = pd.DataFrame(data, columns=["data1", "data2"])

fig = go.Figure(
                    range=[0, 1],
                    label="Data 1"
                    range=[0, 1],
                    constraintrange=[0, 0.5],
                    label="Data 2"


Thank you very much for your answer.

Itโ€™s a solution but itโ€™s not different from just doing it manually in the html file.
my need is really to have the lines going to lower values that are in the foreground.

an idea was to use
but it just reverses the colours. So a similar but working idea would be to literally reverse the axis (display the lower values in the top) the problem is that I do not know a method to do it.

Oh thatโ€™s quite easy - see my code above. Just change the range property from [0, 1] to [1, 0].

Thank you very much.
Unfortunately, it does not work the blue lines are still behind the yellow ones. :smiling_face_with_tear: