Consider the following data:
df = pd.DataFrame([['green','tree',2],
['green','leaf',3],
['red','tomato',1],
['red','pepper',5],
['red','apple', 1]], columns=['color', 'object', 'value'])
The dataframe looks like this:
I'd like to use seaborn.catplot
to produce a barplot of the various categories:
sns.catplot(data=df, kind='bar', x='object', y='value', col='color');
However, I'd like to exclude the objects that don't belong to a given category (i.e. in the first graph I want to exclude 'tomato'
, 'pepper'
and 'apple'
, while in the second plot I want to exclude 'tree'
and 'leaf'
). How can I achieve this?