Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

background_image

Add Background Image to ggplot2


Description

Add background image to ggplot2.

Usage

background_image(raster.img)

Arguments

raster.img

raster object to display, as returned by the function readPNG()[in png package] and readJPEG() [in jpeg package].

Author(s)

Alboukadel Kassambara <alboukadel.kassambara@gmail.com>

Examples

## Not run: 
install.packages("png")

# Import the image
img.file <- system.file(file.path("images", "background-image.png"),
                       package = "ggpubr")
img <- png::readPNG(img.file)

# Plot with background image
ggplot(iris, aes(Species, Sepal.Length))+
 background_image(img)+
 geom_boxplot(aes(fill = Species), color = "white")+
 fill_palette("jco")
 
## End(Not run)

ggpubr

'ggplot2' Based Publication Ready Plots

v0.4.0
GPL-2
Authors
Alboukadel Kassambara [aut, cre]
Initial release
2020-06-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.