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

Plotly express scatterplot legend & color

Hi all,

I hope I can clarify Plotly express regarding scatterplot

I followed through the exact tutorial from the documentation, however if you look at the legend on the right side, the column name I passed for color (species) is prefixed for each label.

Is threre a reason as to why the results on the legend display are different?
And also, how can I fix this and make this neat?

import plotly_express as px

df =
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")

My result

Documentation result

Thanks for your time for reading!

Found this thread.

This could serve as solution.

Hi @lucaseo1991 legend titles were introduced in plotly 4.5, if you upgrade your version of plotly you will have legend titles used automatically in plotly express functions. Also see