Discrete colors in px.scatter ascending order integers

Yeah, it’s not a hack, actually.

Plotly express does some work for you under the hood like grouping your dataframe and plot each group as plotly.graph_objects trace.

I assumed the grouping to be in sequential order of the unique values found in your feature1 column. By sorting the column, you assured the order to be ascending. You could try sorting it descending, if the order of the traces is reversed, it backs my theory :joy:

1 Like