Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

n_pages

Determine the number of pages in a paginated facet plot


Description

This is a simple helper that returns the number of pages it takes to plot all panels when using facet_wrap_paginate() and facet_grid_paginate(). It partially builds the plot so depending on the complexity of your plot it might take some time to calculate...

Usage

n_pages(plot)

Arguments

plot

A ggplot object using either facet_wrap_paginate or facet_grid_paginate

Value

If the plot uses using either facet_wrap_paginate or facet_grid_paginate it returns the total number of pages. Otherwise it returns NULL

Examples

p <- ggplot(diamonds) +
  geom_point(aes(carat, price), alpha = 0.1) +
  facet_wrap_paginate(~ cut:clarity, ncol = 3, nrow = 3, page = 1)
n_pages(p)

ggforce

Accelerating 'ggplot2'

v0.3.3
MIT + file LICENSE
Authors
Thomas Lin Pedersen [cre, aut] (<https://orcid.org/0000-0002-5147-4711>), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.