Use dodge inside a plot but not across different plots in the grid

Viewed 39

Using seaborn I'd like to visualise some data where the categories are nested: I separate by 'col' but then also by hue. The hue classification is a finer classification than the column one. For this plot, I'd like there to be hue dodging inside a single plot but not accross the grid.

Code to reproduce:

import seaborn as sns

df = sns.load_dataset("penguins")
df['category'] = 'small'
df.category.mask(df.species == 'Gentoo', 'big', inplace=True)

# 'category' is a coarser classification than species
sns.catplot(data=df, y='body_mass_g', col='category', hue='species', x='island', kind='bar');

The problem: The hues in the right hand part (Gentoo) dodge the hues that are only used in the left hand part (Adelie, Chinstrap). I'd like to avoid this. It would be something to the effect of enabling dodge inside each grid cell but not globally.

catplot from the code

0 Answers
Related