16.6 Missing faceting variables

When you add a map layer that doesn’t contain a variable, ggplot will display the map in every facet: missing faceting variables are treated like they have all values.

This is useful when you want to add annotations that make it easier to compare among facets.

df1 <- data.frame(x = 1:3, y = 1:3, gender = c("f", "f", "m"))
df2 <- data.frame(x = 2, y = 2)

ggplot(df1, aes(x, y)) + 
  geom_point(data = df2, colour = "red", size = 2) + 
  geom_point() + 
  facet_wrap(~gender)