Why isn't facet a mappable aesthetic?

I can do:

ggplot(mpg, aes(displ, hwy, colour = class)) + 
  geom_point()

Or I can separate classes using facets:

ggplot(mpg, aes(displ, hwy)) + 
  geom_point() + 
  facet_grid(~class)

But during the design of ggplot2, why was it decided that this wouldn't work?

ggplot(mpg, aes(displ, hwy, facet = class)) + 
  geom_point()

My (totally uneducated) guess would be that aesthetics are applied to each geom individually—they can inherit aesthetics from the ggplot call, but they can also override aesthetics. But facets are an all-or-nothing affair: they're either applied to the entire plot or not at all. For example, I can't really conceptualise what a plot like this would look like:

ggplot(mpg, aes(displ, hwy)) +
   geom_point() +
   geom_smooth(aes(facet = class))

You could try to restrict facets so that they're special aesthetics that can only be applied to the ggplot call, but aesthetics are probably the biggest chunk of cognitive load when you're learning ggplot2, and I think there's a lot of value in keeping them conceptually consistent. Plot components that are added, in contrast, are a fairly low cognitive load, so I think it makes more sense to implement more 'edge casey' plot features through them.

4 Likes