Categorical Plots: stripplot, swarmplot, boxplot
You'll learn how to compare distributions across categories using Seaborn's strip, swarm, and box plots.
The Core Idea
When you have a continuous variable (like salary, temperature, or test scores) and want to see how it varies across different categories (like departments, cities, or classes), categorical plots are your best friend. Seaborn offers three complementary ways to visualize these comparisons:
stripplot(): Shows every data point scattered along a categorical axis—like dots lined up in vertical columnsswarmplot(): Similar to stripplot, but adjusts points horizontally so they don't overlap, creating a "swarm" shape that reveals densityboxplot(): Summarizes each category with a box showing quartiles, median, and outliers
Think of it like comparing heights across different sports teams. A stripplot shows every player's height stacked vertically. A swarmplot spreads players out so you see clustering patterns. A boxplot gives you the statistical summary: median height, spread, and unusually tall/short players.
When to Use Each
Use stripplot when you have relatively few points and want to show individual values simply. Use swarmplot when you want to see both individual points and distribution density (though it can get messy with many points). Use boxplot when you need a clean statistical summary or have too many points to show individually.
These plots share similar syntax: specify your categorical variable on one axis and continuous variable on the other. You can combine them—for example, overlaying a stripplot on a boxplot to show both summary statistics and raw data.
Key Takeaway: Strip, swarm, and box plots let you compare how a continuous variable distributes across categories—stripplot shows all points, swarmplot reveals density patterns, and boxplot provides statistical summaries.