mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2025-09-12 09:59:39 +02:00
feat: even more arguments available when using wrap_plot_list
This commit is contained in:
parent
d700658f5c
commit
46db0bd5e4
1 changed files with 24 additions and 15 deletions
|
@ -738,7 +738,10 @@ line_break <- function(data, lineLength = 20, force = FALSE) {
|
||||||
#' @param data list of ggplot2 objects
|
#' @param data list of ggplot2 objects
|
||||||
#' @param tag_levels passed to patchwork::plot_annotation if given. Default is NULL
|
#' @param tag_levels passed to patchwork::plot_annotation if given. Default is NULL
|
||||||
#' @param title panel title
|
#' @param title panel title
|
||||||
#' @param ... ignored for argument overflow
|
#' @param guides passed to patchwork::wrap_plots()
|
||||||
|
#' @param axes passed to patchwork::wrap_plots()
|
||||||
|
#' @param axis_titles passed to patchwork::wrap_plots()
|
||||||
|
#' @param ... passed to patchwork::wrap_plots()
|
||||||
#'
|
#'
|
||||||
#' @returns list of ggplot2 objects
|
#' @returns list of ggplot2 objects
|
||||||
#' @export
|
#' @export
|
||||||
|
@ -747,6 +750,9 @@ wrap_plot_list <- function(data,
|
||||||
tag_levels = NULL,
|
tag_levels = NULL,
|
||||||
title = NULL,
|
title = NULL,
|
||||||
axis.font.family = NULL,
|
axis.font.family = NULL,
|
||||||
|
guides = "collect",
|
||||||
|
axes = "collect",
|
||||||
|
axis_titles = "collect",
|
||||||
...) {
|
...) {
|
||||||
if (ggplot2::is_ggplot(data[[1]])) {
|
if (ggplot2::is_ggplot(data[[1]])) {
|
||||||
if (length(data) > 1) {
|
if (length(data) > 1) {
|
||||||
|
@ -762,9 +768,9 @@ wrap_plot_list <- function(data,
|
||||||
})() |>
|
})() |>
|
||||||
align_axes() |>
|
align_axes() |>
|
||||||
patchwork::wrap_plots(
|
patchwork::wrap_plots(
|
||||||
guides = "collect",
|
guides = guides,
|
||||||
axes = "collect",
|
axes = axes,
|
||||||
axis_titles = "collect",
|
axis_titles = axis_titles,
|
||||||
...
|
...
|
||||||
)
|
)
|
||||||
if (!is.null(tag_levels)) {
|
if (!is.null(tag_levels)) {
|
||||||
|
@ -784,15 +790,19 @@ wrap_plot_list <- function(data,
|
||||||
cli::cli_abort("Can only wrap lists of {.cls ggplot} objects")
|
cli::cli_abort("Can only wrap lists of {.cls ggplot} objects")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is.null(axis.font.family)) {
|
||||||
if (inherits(x = out, what = "patchwork")) {
|
if (inherits(x = out, what = "patchwork")) {
|
||||||
out &
|
out <- out &
|
||||||
ggplot2::theme(axis.text = ggplot2::element_text(family = axis.font.family))
|
ggplot2::theme(axis.text = ggplot2::element_text(family = axis.font.family))
|
||||||
} else {
|
} else {
|
||||||
out +
|
out <- out +
|
||||||
ggplot2::theme(axis.text = ggplot2::element_text(family = axis.font.family))
|
ggplot2::theme(axis.text = ggplot2::element_text(family = axis.font.family))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#' Aligns axes between plots
|
#' Aligns axes between plots
|
||||||
#'
|
#'
|
||||||
|
@ -819,7 +829,6 @@ align_axes <- function(...,x.axis=TRUE,y.axis=TRUE) {
|
||||||
xr <- clean_common_axis(p, "x")
|
xr <- clean_common_axis(p, "x")
|
||||||
|
|
||||||
suppressWarnings({
|
suppressWarnings({
|
||||||
p |>
|
|
||||||
purrr::map(p, \(.x){
|
purrr::map(p, \(.x){
|
||||||
out <- .x
|
out <- .x
|
||||||
if (isTRUE(x.axis)) {
|
if (isTRUE(x.axis)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue