Change default colors to stacked bar in plotly.express

I am new to Plotly.

import plotly.express as px

fig = px.bar(case_by_region, x=‘Year’, y=‘Total Count’, color=‘Country’, barmode=‘stack’, height=800)

fig.update_layout(
xaxis_type=‘category’,
title_text=‘Cases by Region for past 3 years’,
plot_bgcolor=‘rgba(0, 0, 0, 0)’,
title_x=0.5,
legend_orientation=“h”
)

I am wondering how to change the default color scheme?

Thanks,
David

Hi @david529, welcome to the forum! You can use the discrete_color_sequence for this, for example

import plotly.express as px
df = px.data.tips()
fig = px.bar(df, x='day', y='tip', color='time',
             color_discrete_sequence=px.colors.qualitative.D3)
fig.show()


See https://plot.ly/python/discrete-color/ for more on discrete colors, including a list of built-in colorscales and how to build your own.