Customizing Facet Labels and Strips
You'll learn how to polish your faceted plots by controlling the appearance and text of the facet labels (strips) that identify each subplot.
What Are Facet Strips?
When you create faceted plots with facet_wrap() or facet_grid(), each panel gets a strip—that gray box at the top or side showing which subset of data you're viewing (like "Species: setosa"). Think of strips as name tags for your small multiples. By default, they're functional but plain. Customizing them makes your visualization more readable and professional.
Controlling Strip Text with Labeller Functions
The labeller functions let you rename or reformat strip text without changing your underlying data. The most common is labeller(), which accepts a named list or function:
# Replace variable values with cleaner names
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
facet_wrap(~ class, labeller = labeller(class = c(
"2seater" = "Two Seater",
"suv" = "SUV"
)))
Use label_both to show both the variable name and value (e.g., "Species: setosa") or label_value for just the value.
Styling Strips with Theme Elements
Customize strip appearance using theme() components:
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
facet_wrap(~ class) +
theme(
strip.background = element_rect(fill = "steelblue"),
strip.text = element_text(color = "white", face = "bold", size = 12)
)
Use strip.text.x and strip.text.y to target horizontal or vertical strips separately. You can also control strip position and remove backgrounds entirely with element_blank().
Key Takeaway: Customize facet strips using labeller functions for text content and theme() elements like strip.background and strip.text for visual styling, transforming generic labels into clear, branded identifiers for your multi-panel plots.