addImg: Add image to plot region

View source: R/addImg.R

addImgR Documentation

Add image to plot region

Description

Add image to plot region

Usage

addImg(obj, x = NULL, y = NULL, width = NULL, interpolate = TRUE)

Arguments

obj

an image file imported as an array (e.g. png::readPNG, jpeg::readJPEG)

x

mid x coordinate for image

y

mid y coordinate for image

width

width of image (in x coordinate units)

interpolate

(passed to graphics::rasterImage) A logical vector (or scalar) indicating whether to apply linear interpolation to the image when drawing.

Value

adds graphics to plot

Examples



library(png)
myurl <- paste0("https://upload.wikimedia.org/wikipedia/commons/thumb/", 
  "e/e1/Jupiter_%28transparent%29.png/242px-Jupiter_%28transparent%29.png")
myurl <- paste0("https://upload.wikimedia.org/wikipedia/commons/4/47/",
  "PNG_transparency_demonstration_1.png")
z <- tempfile()
download.file(myurl,z,mode="wb")
pic <- readPNG(z)
file.remove(z) # cleanup
dim(pic)

image(volcano)
addImg(pic, x = 0.3, y = 0.5, width = 0.5)



marchtaylor/sinkr documentation built on July 4, 2022, 5:48 p.m.