Two closely-related charts: barplot shows an aggregate (mean by default) of a numeric value per category, and countplot shows the count of rows per category. Both add error bars and grouping for free.
barplot — aggregate a value
sns.barplot(data=tips, x="day", y="total_bill") # mean bill per day + CIsns.barplot(data=tips, x="day", y="total_bill", hue="sex") # grouped barssns.barplot(data=tips, x="day", y="total_bill", estimator="median", errorbar=None)
countplot — count rows
sns.countplot(data=tips, x="day") # how many rows per daysns.countplot(data=tips, x="day", hue="sex") # grouped counts
Key takeaways
- 01barplot shows an aggregate (mean by default) of a value per category, with a CI.
- 02countplot shows the number of rows per category (no y).
- 03estimator changes the aggregation (median, sum…); errorbar controls the interval.
- 04hue groups both into side-by-side bars.
