catplot is Seaborn’s figure-level function for comparing numeric values across categorical variables. Choose the category for x, the measured value for y, and a plot kind such as a boxplot. section 11.16 section 11.18
A typical categorical comparison follows this pattern:
- Pass a pandas DataFrame through data. section 11.16
- Use x for the categories being compared and y for the values being measured. section 11.18
- Set kind='box' to compare each category’s distribution rather than displaying individual observations. section 11.18
Compare taxi fares by month
After loading January and July taxi records and deriving a month column, use sns.catplot(x='month', y='total_amount', data=df, kind='box'). The resulting boxplot compares total-amount distributions for the two months; df.groupby('month')['total_amount'].mean() supplies a numerical follow-up. section 11.18
sns.catplot(x='city', y='max_temp', data=df, kind='box')
Inspect the executable weather example that draws a boxplot of maximum temperatures for each city. section 11.16
