-
Notifications
You must be signed in to change notification settings - Fork 110
Description
Hi 👋,
I’d like to suggest a feature that would make facet_col() more flexible: adding a data parameter, similar to how it works in ggplot() or geom_*() layers.
Motivation
Currently, facet_col() does not accept a data argument, so the faceting variable must exist in the main data passed to ggplot(). This can be limiting when:
-
The variable you'd like to facet by exists in a separate data frame
-
You’re layering multiple data sources in a single plot
While it is possible to work around this by joining the data frames beforehand, being able to directly specify data = df inside facet_col() would streamline this process and align better with tidyverse-style workflows.
Example (Currently not possible):
ggplot(df1, aes(x, y)) +
geom_point() +
facet_col(data = df2, vars(group))
This currently throws an error since facet_col() does not support a data parameter.
Proposed Behavior
Support for data = ... in facet_col() (and possibly in facet_row() as well), with internal handling that merges or references the appropriate facetting structure without requiring manual pre-joins.
Thank you for considering this!