#' grobs
#' @param options parameters (except `plotlist`) of [cowplot::plot_grid()]
#' @keywords internal
#' @export
grobs <- function(..., options = list(nrow = 1)) {
params = c(plotlist = list(...), options)
do.call(cowplot::plot_grid, params)
}
#' add grob to a plot
#'
#' @param p ggplot object
#' @param ... grob objects
#' @param ggplot logical, if TRUE, return a ggplot object
#'
#' @example R/examples/ex-add_grob.R
#'
#' @import ggplotify
#' @export
add_grob <- function(p, ..., ggplot = TRUE) {
g = grid::grobTree(
as.grob(p),
grid::grobTree(...,
vp = grid::viewport()
)
)
if (ggplot) as.ggplot(g) else g
}
annotation_custom2 <- function(grob, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, data) {
layer(
data = data, stat = StatIdentity, position = PositionIdentity,
geom = ggplot2:::GeomCustomAnn,
inherit.aes = TRUE, params = list(
grob = grob,
xmin = xmin, xmax = xmax,
ymin = ymin, ymax = ymax
)
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.