Open
Description
Is there any way to extract the facet to page mapping when using facet_wrap_paginate()
and facet_grid_paginate()
? I'm hoping that there is a function like paginate_data_map()
(which I know doesn't exist) that would extract the information of which facet is on which page similar to the example below:
library(tidyverse)
library(ggforce)
mtcars_double <-
mtcars |>
crossing(double = 1:2) |>
mutate(
cyl = double*cyl
)
ggplot(mtcars_double, aes(x = disp, y = hp)) +
geom_point() +
facet_wrap_paginate(~cyl, nrow = 2, ncol = 2)
# desired output would be a data.frame or tibble that looks something like the
# following with one column for the page and more columns for each of the
data.frame(
page = c(1, 1, 1, 1, 2),
cyl = c(4, 6, 8, 12, 16)
)
#> page cyl
#> 1 1 4
#> 2 1 6
#> 3 1 8
#> 4 1 12
#> 5 2 16
Created on 2024-03-24 with reprex v2.1.0
If it doesn't exist and would be of interest, I could try to make a PR for it with guidance about where to find the information within the gg object.
FYI, this is for use in the ggtibble
package so that I can automatically expand the pages into a gglist
and ggtibble
object there.
Metadata
Metadata
Assignees
Labels
No labels