How can I change in plotly express the color of a specific bar in a bar graph. For example, I want to change the color to purple , to the German Shephard (from the breed).
fig = px.bar(data_frame=df, x="quantity", y="dogs", orientation='h', color='dogs',hover_name='breed',)
Thanks.
You can make a discrete_color_map dictionary like this:
color_discrete_map = {'German Shephard': 'rgb(255,0,0)'}
And pass it into your parameters when creating the bar chart like this:
fig = px.bar(data_frame=df, x="quantity", y="dogs", orientation='h', color='dogs',hover_name='breed',color_discrete_map = color_discrete_map)
Here is the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With