Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ src/*.o
src/*.so
src/*.dll
inst/doc
._*
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BugReports: https://github.com/thomasp85/ggforce/issues
License: GPL (>=2)
LazyData: TRUE
Depends:
ggplot2 (>= 2.2.0),
ggplot2 (>= 2.2.1.9000),
R (>= 3.3.0)
Imports:
Rcpp (>= 0.12.2),
Expand All @@ -41,7 +41,7 @@ Suggests:
devtools,
reshape2
VignetteBuilder: knitr
Collate:
Collate:
'RcppExports.R'
'aaa.R'
'shape.R'
Expand All @@ -58,6 +58,7 @@ Collate:
'facet_stereo.R'
'facet_wrap_paginate.R'
'facet_zoom.R'
'gen_all_pages_fwp.R'
'ggforce_package.R'
'ggproto-classes.R'
'interpolate.R'
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export(facet_stereo)
export(facet_wrap_paginate)
export(facet_zoom)
export(gather_set_data)
export(gen_all_pages_fwp)
export(geom_arc)
export(geom_arc0)
export(geom_arc2)
Expand Down
6 changes: 5 additions & 1 deletion R/facet_wrap_paginate.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ FacetWrapPaginate <- ggproto("FacetWrapPaginate", FacetWrap,
#' n_pages(p)
#'
n_pages <- function(plot) {
page <- ggplot_build(plot)$layout$panel_layout$page
if (utils::packageVersion('ggplot2') <= '2.2.1') {
page <- ggplot_build(plot)$layout$panel_layout$page
} else {
page <- ggplot_build(plot)$layout$layout$page
}
if (!is.null(page)) {
max(page)
} else {
Expand Down
29 changes: 29 additions & 0 deletions R/gen_all_pages_fwp.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#' Generate all pages with facet_wrap_paginate
#'
#' This is a wrapper for [facet_wrap_paginate()] to generate all of the pages,
#' rather than just one at a time.
#'
#' @inheritParams facet_wrap_paginate
#' @inheritDotParams facet_wrap_paginate
#' @param plot A ggplot object.
#' @return A list, where each element is one page of plots.
#' @family ggforce facets
#' @examples
#' g <- ggplot(diamonds, aes(x = cut, y = price)) + geom_boxplot()
#' gl <- gen_all_pages_fwp(g, "color", nrow = 2, ncol = 3)
#' gl[[1]]
#' @export

gen_all_pages_fwp <- function(plot, facets, ...){
dots <- list(...)
if (is.null(dots$nrow) || is.null(dots$ncol)){
msg <- paste("nrow and/or ncol is NULL. Please supply values for both",
"arguments; otherwise, call facet_wrap directly.")
stop(msg)
}
n <- n_pages(plot + facet_wrap_paginate(facets, ..., page = 1))
plot_list <- lapply(1:n, function(i) {
plot + facet_wrap_paginate(facets, ..., page = i)
})
return(plot_list)
}
2 changes: 1 addition & 1 deletion man/facet_grid_paginate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/facet_stereo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/facet_wrap_paginate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/facet_zoom.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions man/gen_all_pages_fwp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/scale_unit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.