liveBook · Manning

Facet plot

As explained in Statistics Slam Dunk

A facet plot is a collection of subplots with shared axes, where each panel represents a group or factor in the data.

A facet plot compares groups by splitting data into multiple subplots, or panels, that share horizontal and vertical axes. Each panel represents a factor or mutually exclusive subset while keeping the visual structure otherwise alike. section 1.2.1 section 9.5.2

Use facet plots to make grouped comparisons while preserving a common visual scale:

  • Draw one subplot for every factor or group in the data. section 1.2.1
  • Build each panel with the same axes so distributions or counts remain comparable. section 1.2.1
  • Use ggplot2's facet_wrap() to arrange panels, customize the number of columns with ncol, and optionally free the scales. section 9.5.2

NBA wins by prior days off

A 25-panel ggplot2 visualization compares home and away win totals for every combination of zero through four prior days off. Horizontal bars encode win totals, panels are arranged by the two days-off variables, and geom_text() adds count labels. Fixed x-axis scales make comparisons consistent; xlim() creates room for labels. section 9.5.2

Figure 1.2 Visualizations of automobile data using the ggplot2 package
CH01_F02_Sutton

Inspect a four-panel automobile example that uses ggplot2 visualizations, including a facet plot of miles-per-gallon distributions grouped by cylinders and transmission. section 1.2.1

How Statistics Slam Dunk covers it

How deep it goes
Defines panels and demonstrates facet_wrap(), layout control, labels, and fixed versus free scales.
Examples
Uses mtcars distributions and NBA home-away win totals across 25 prior-days-off permutations.
What it assumes
Assumes a grouped data set and basic ggplot2 plotting, while defining factors and shared axes directly.
What you can do after
Apply it via ggplot2 to construct, label, arrange, and interpret grouped panels.
How it connects
Connects ggplot2, factors, boxplots, bar charts, and data wrangling.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Slam Dunk. The section links point to the parts of the book it draws on.