R/ggbackground.R

Defines functions ggbackground

Documented in ggbackground

##' set background for ggplot
##'
##'
##' @title ggbackground
##' @param gg gg object
##' @param background background image
##' @param ... additional parameter to manipulate background image, see also geom_image
##' @return gg object
##' @importFrom ggplot2 ggplot
##' @export
##' @author guangchuang yu
ggbackground <- function(gg, background, ...) {
    ggplot(data.frame(x = 0:1, y = 0:1), aes_(x = ~x, y = ~y)) +
        geom_image(image = background,size=Inf, ...) +
        geom_subview(subview = gg + theme_transparent(),
                     width=Inf, height=Inf, x=.5, y=.5) +
        theme_nothing()
}
GuangchuangYu/ggimage documentation built on June 24, 2018, 4:35 p.m.