Hi,
is there any way to change default scatter colors in this code?
import plotly.express as px
iris = px.data.iris()
fig = px.scatter_matrix(iris,
dimensions=["sepal_width", "sepal_length", "petal_width", "petal_length"],
color="species")
fig.show()
I’d like to change default color blue and red to green and orange; orange for species X, green for species Y
If you could help.
Thanks
1 Like
Late here but came across this looking for same thing, so likely others too. I found the Express thing (and “color” param only accepting dataset grouping without override for single immediate fixed color) a bit odd at first - Plotly express bar colour change points out you need to know the wider Plotly.py first… (so why not just drop Express is the first thought!). But I bore with it and now worked out on Express we just need:
color_discrete_sequence=['green', 'orange']
which you can use for both single color change or sequenced as per OP. Traces and markers are used on Plotly.py.
It’s worth not swerving the doc on plotly.express package — 5.1.0 documentation
Hope this helps someone else - am loving Plotly’s hover-overs which massively beats base charting packages!