diff --git a/NAMESPACE b/NAMESPACE index f315ec2..d79ffef 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -101,6 +101,8 @@ importFrom(ggplot2,is.ggplot) importFrom(ggplot2,is.theme) importFrom(ggplot2,labs) importFrom(ggplot2,margin) +importFrom(ggplot2,max_height) +importFrom(ggplot2,max_width) importFrom(ggplot2,panel_cols) importFrom(ggplot2,panel_rows) importFrom(ggplot2,scale_x_continuous) @@ -140,6 +142,7 @@ importFrom(gtable,gtable_add_rows) importFrom(gtable,gtable_height) importFrom(gtable,gtable_width) importFrom(gtable,is.gtable) +importFrom(stats,ave) importFrom(stats,na.omit) importFrom(utils,as.roman) importFrom(utils,modifyList) diff --git a/R/collect_axes.R b/R/collect_axes.R index 952e34b..114f905 100644 --- a/R/collect_axes.R +++ b/R/collect_axes.R @@ -136,6 +136,7 @@ collect_axes <- function(gt, dir = "x") { # For every given row, check if all non-zero grobs occupying that row have a # name that has a pattern. If all these grobs in that row do, measure the # grob heights and put that into the gtable's heights. +#' @importFrom ggplot2 max_height retrofit_rows <- function(gt, rows, pattern = NULL) { if (is.null(pattern) || length(rows) == 0) { return(gt) @@ -166,6 +167,7 @@ retrofit_rows <- function(gt, rows, pattern = NULL) { # For every given column, check if all non-zero grobs occupying that column # have a name that has a pattern. If all these grobs in that column do, measure # the grob widths and put that into the gtable's widths. +#' @importFrom ggplot2 max_width retrofit_cols <- function(gt, cols, pattern = NULL) { if (is.null(pattern) || length(cols) == 0) { return(gt) @@ -240,6 +242,7 @@ is_zero <- function(x) { } # Determine uniqueness of grobs +#' @importFrom stats ave grob_id <- function(grobs, layout, byrow, merge = FALSE) { # Hash the grobs to determine unique grobs diff --git a/R/inset_element.R b/R/inset_element.R index 79e27e3..2ba4d88 100644 --- a/R/inset_element.R +++ b/R/inset_element.R @@ -35,9 +35,11 @@ #' # Grobs and other objects can be added as insets as well #' p1 + inset_element(grid::circleGrob(), 0.4, 0.4, 0.6, 0.6) #' -#' logo <- system.file('help', 'figures', 'logo.png', package = 'patchwork') -#' logo <- png::readPNG(logo, native = TRUE) -#' p1 + inset_element(logo, 0.8, 0.8, 1, 1, align_to = 'full') +#' if (requireNamespace('png', quietly = TRUE)) { +#' logo <- system.file('help', 'figures', 'logo.png', package = 'patchwork') +#' logo <- png::readPNG(logo, native = TRUE) +#' p1 + inset_element(logo, 0.8, 0.8, 1, 1, align_to = 'full') +#' } #' #' # Just as expected insets are still amenable to changes after the fact #' p1 + diff --git a/man/inset_element.Rd b/man/inset_element.Rd index 23d71aa..1f6f498 100644 --- a/man/inset_element.Rd +++ b/man/inset_element.Rd @@ -57,9 +57,11 @@ p1 + inset_element(p2, 0, 0.6, 0.4, 1, align_to = 'full') # Grobs and other objects can be added as insets as well p1 + inset_element(grid::circleGrob(), 0.4, 0.4, 0.6, 0.6) -logo <- system.file('help', 'figures', 'logo.png', package = 'patchwork') -logo <- png::readPNG(logo, native = TRUE) -p1 + inset_element(logo, 0.8, 0.8, 1, 1, align_to = 'full') +if (requireNamespace('png', quietly = TRUE)) { + logo <- system.file('help', 'figures', 'logo.png', package = 'patchwork') + logo <- png::readPNG(logo, native = TRUE) + p1 + inset_element(logo, 0.8, 0.8, 1, 1, align_to = 'full') +} # Just as expected insets are still amenable to changes after the fact p1 + diff --git a/man/plot_layout.Rd b/man/plot_layout.Rd index 979dc3d..894e479 100644 --- a/man/plot_layout.Rd +++ b/man/plot_layout.Rd @@ -14,7 +14,7 @@ plot_layout( tag_level = NULL, design = NULL, axes = NULL, - axis_titles = NULL + axis_titles = axes ) } \arguments{