When using hue parameter on barplot in Seaborn it changes the color and the position of the bars. Like the following exemple:
Plot without hue:
import seaborn as sns
df = {'x': [1, 2, 3, 4], 'y': [5, 6, 7, 8], 'hue': ['a', 'b', 'b', 'a']}
sns.barplot(
data = df,
x = 'x',
y = 'y',
)
Output: Seaborn barplot without hue
Plot with hue:
df = {'x': [1, 2, 3, 4], 'y': [5, 6, 7, 8], 'hue': ['a', 'b', 'b', 'a']}
sns.barplot(
data = df,
x = 'x',
y = 'y',
hue = 'hue'
)
Output: Seaborn barplot with hue
So how can I make a plot with the default bar position and the colors made by hue?