Returns a plot that displays an image. It enables users to directly include a .png or a .jpeg file in a plot region by providing their path.

plotImage(obj = NULL, file = NULL, add = FALSE, ...)

Arguments

obj

an object of class nativeRaster function.

file

a path to either a .png file or a .jpeg file.

add

logical. Should images be added on the current graph? If FALSE a new plot is created.

...

additional arguments to be passed to rasterImage function.

Details

Note that either obj or file must be defined. If a path is provided either readPNG or readJPEG according to the end of the file extension.

Examples

img <- png::readPNG(system.file('img', 'Rlogo.png', package='png'), native=TRUE) op <- par(no.readonly = TRUE) par(mfrow=c(4,4), mar=rep(2,4)) for (i in seq_len(16)) plotImage(img)
par(op)