Controlling Scales Across Facets
You'll learn how to decide whether facets should share the same axis ranges or adapt independently to their own data.
Why Scale Control Matters
By default, facet_wrap() and facet_grid() use the same axis scales across all panels. This makes comparing patterns easy—each panel shows data on an identical grid. But sometimes your subgroups have vastly different ranges, and forcing them to share scales either compresses some data into invisibility or leaves huge empty spaces in others.
Think of it like a clothing store: fixed scales are like displaying all shirts on the same-sized mannequins (easy comparison), while free scales are like custom-fitting each mannequin to its specific shirt size (better individual visibility).
The scales Argument
Control this behavior with the scales parameter in your faceting function:
scales = "fixed"(default): All facets share the same x and y axis rangesscales = "free": Both x and y axes adjust independently per facetscales = "free_x": Only x-axis ranges vary; y-axis stays consistentscales = "free_y": Only y-axis ranges vary; x-axis stays consistent
# Fixed scales - easy comparison
ggplot(data, aes(x = year, y = sales)) +
geom_line() +
facet_wrap(~region, scales = "fixed")
# Free y-axis - each region gets its own vertical range
ggplot(data, aes(x = year, y = sales)) +
geom_line() +
facet_wrap(~region, scales = "free_y")
Use fixed scales when comparing magnitudes across groups matters. Use free scales when you care more about patterns within each group than absolute comparisons between them.
Key Takeaway: The scales argument lets you balance comparability versus visibility—fixed scales enable direct comparison, while free scales reveal detail in each facet's unique data range.