Course contentsShow
← Data Science
Lesson 1186 of 2,14530. Exploratory Data Analysis (EDA) ProcessFree lesson

Box Plots and Violin Plots by Group

Visualizing numeric distributions across categorical groups to compare centers, spreads, and shapes.

Box Plots and Violin Plots by Group

What you'll learn: How to compare numeric distributions across different categories using grouped box plots and violin plots.

When you're conducting bivariate analysis with one categorical and one numeric variable, you often want to see how the distribution changes across groups. Box plots and violin plots are perfect for this—they let you compare centers, spreads, and shapes side-by-side.

Why Use Grouped Plots?

Think of comparing exam scores across different study methods. A single histogram shows you all scores together, but grouping by study method reveals whether one approach consistently yields higher scores, more variability, or skewed distributions.

Box Plots by Group

Box plots display the five-number summary (min, Q1, median, Q3, max) plus outliers for each category. When placed side-by-side, you can instantly compare:

  • Centers: Which group has the highest median?
  • Spreads: Which group shows more variability (wider IQR)?
  • Outliers: Are extreme values concentrated in certain groups?

Violin Plots by Group

Violin plots combine box plots with density curves, showing the full distribution shape. They reveal subtleties box plots miss—like bimodal distributions or long tails. Comparing violins across groups helps you spot whether one category has a fundamentally different shape of distribution.

Practical Use

After calculating grouped summary statistics (lesson 1185), these visualizations bring those numbers to life. You can confirm that differences in means or medians reflect real distributional shifts, not just outliers or skewness in one group.

Key Takeaway: Box plots and violin plots grouped by category provide a visual comparison of how numeric distributions differ across groups, revealing patterns in center, spread, and shape that summary statistics alone might obscure.