For the code below I am trying to create a barplot. If the column name in column ACQUISITION_CHANNEL = 'Referral' then the bar should be red else grey.
g = sns.catplot(
data=df, kind="bar",
x="CITY", y="CUSTOMERS", hue="ACQUISITION_CHANNEL",
ci="sd", palette=clrs, alpha=.6, height=8
)
g.despine(left=False)
g.set_axis_labels("", "Share Total Customers for each City (%)")
g.legend.set_title("")
This is what I have tried so far, but it did not work
values = df.Customers
clrs = ['grey' if (x < max(values)) else 'red' for x in values ]
You can specify a
dict
that maps the values used for thehue
parameter to matplotlib colours, see the second example under point plots.