Combine two facet_wrap extensions (facet_rep_wrap and facet_wrap_paginate)

Viewed 51

I have found 2 useful ggplot2 extensions:

  • lemon::facet_rep_wrap() repeats axis lines and labels across all facet panels
  • ggforce::facet_wrap_paginate() splits facet panels over multiple plots

Now, I would like to apply both extensions in the same plot (repeat axis labels and split over multiple plots)

Example:

library(ggplot2)

p <- ggplot(data = mpg) +
  geom_point(aes(x = cty, y = hwy))

## Default
p + facet_wrap(~ manufacturer)
## Repeat x-axis labels
p + lemon::facet_rep_wrap(~ manufacturer, repeat.tick.labels = "x")
## Split over multiple plots
p + ggforce::facet_wrap_paginate(~ manufacturer, nrow = 2, ncol = 2, page = 1)

How can I combine facet_rep_wrap and facet_wrap_paginate?

Internally, they call ggproto(NULL, FacetWrapRepeatLabels, ...) and ggproto(NULL, FacetWrapPaginate, ...), respectively. Can I combine the two objects FacetWrapRepeatLabels and FacetWrapPaginate? How can I do this?

0 Answers
Related