addIMGtopanel: Add images to a ggplot facet plot

Description Usage Arguments Examples

View source: R/addIMGtopanel.R

Description

This adds images in a image list to the panels in a ggplot object.

Usage

1
addIMGtopanel(p1, img.list, pal = colorRamps::matlab.like(100))

Arguments

p1

A ggplot object with panels, i.e..

img.list

A list of images for each center. Image 1 goes with panel 1, etc. Panels are numbered across rows. Image are recycled if the list is shorter than the number of panels.

pal

The color ramp for the images. This will determine what the images look like.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
img.list <- list()
for(i in 1:3) img.list[[i]] <- raster::as.raster(matrix(stats::runif(4),2,2))

library(ggplot2)
p <- ggplot(mtcars, aes(x=mpg, y=hp)) + geom_line() + facet_wrap(~cyl)

addIMGtopanel(p, img.list)


#In this example, the images are cut off at the top.
p <- ggplot(mtcars, aes(x = mpg, y = wt)) + geom_point() + 
     facet_grid(vs + am ~ gear, margins = TRUE)

addIMGtopanel(p, img.list)

UW-Upwelling-Project/imageryML documentation built on Dec. 18, 2021, 6:11 p.m.