Skip to content

Facet specification for the Grammar of Graphics "add" operator #3357

Closed
@paleolimbot

Description

@paleolimbot

@clauswilke recently suggested that it would be nice to be able to generate this without resorting to composing plots:

library(ggplot2)
library(patchwork)

p1 <- ggplot(mtcars, aes(disp, mpg)) + geom_point()
p2 <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
p1 + p2

Created on 2019-06-06 by the reprex package (v0.2.1)

I wonder if nested tibbles could be used (currently they fail epicly):

library(ggplot2)
library(tibble)

ggplot(mtcars, aes(x = tibble(disp, wt), y = mpg)) +
  geom_point()
#> Don't know how to automatically pick scale for object of type tbl_df/tbl/data.frame. Defaulting to continuous.
#> Error: Aesthetics must be either length 1 or the same as the data (32): x

Created on 2019-06-06 by the reprex package (v0.2.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions