For example:
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
sns.set_style('darkgrid')
fig, ax = plt.subplots()
a = pd.DataFrame({'Program': ['A', 'A', 'B', 'B', 'Total', 'Total'],
'Scenario': ['X', 'Y', 'X', 'Y', 'X', 'Y'],
'Duration': [4, 3, 5, 4, 9, 7]})
g = sns.barplot(data=a, x='Scenario', y='Duration',
hue='Program', ci=None)
I want x=X
and x=Y
have different color, but same color for each hue(A, B, Total ...) . ( There may be more Scenario than two ) .
How do I change bar color according to x name instead of hue ?
I am not aware of any straightforward way to set the colors like that using
sns.barplot
. Here is how can do this using pandas instead: