0

Is there a way to customize the colors of individual bars in a group bar chart?

In here, under the section "Customizing Individual Bar Colors" shows the manner in which customization can be done for the regular bar charts.

But in barmode=group settings, I could only set the colors for the group. Am wondering how I can customize the colors for a single bar.

fig_company = px.bar(
    df,
    y = "company",
    x = "revenue",
    color = "region",
    orientation = 'h',
    text_auto = True,
    barmode="group",
    color_discrete_map={
        "south":"#DBCFB0",
        "north":"#545775"}
)
Beavis
  • 94
  • 9
  • 1
    [See if this Q & A helps](https://stackoverflow.com/questions/65338539/how-to-color-bars-in-grouped-plotly-bar-chart) – Kat Jan 25 '23 at 02:24
  • Thank you @Kat. Tried to implement it, but ran into other problems due to my limited skills. – Beavis Jan 26 '23 at 00:24
  • If you need more than 'point me in the right direction' (and maybe even then...)...To get great answers quickly, I would highly encourage you to make your question reproducible. That means including your data, or a subset of your data, packages you're using, and the code sufficient to see what we're working with. To share your data, if you used a pandas data frame, extract the data with `pd.DataFrame.to_dict` and copy the output exactly as it appears. If you used base Python data structures, try `repr` (no import needed). – Kat Jan 26 '23 at 01:22
  • Thanks for the advice @Kat. I will work towards what you suggested. – Beavis Jan 26 '23 at 06:16
  • You can edit this question, so I can still help you. – Kat Jan 26 '23 at 14:39

0 Answers0