问题
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 ?
来源:https://stackoverflow.com/questions/60631698/seaborn-change-bar-color-according-to-x-name-instead-of-hue