| iraster {iplots} | R Documentation |
iraster adds a raster image as an iObj to the given iPlot.
Position in the plot is specified by bottom-left and top-right points
of the image.
iraster(x1, y1, x2, y2, img, ..., plot = iplot.cur())
x1, y1, x2, y2 |
coordinates of the bottom-left (x1, y1) and
top-right (x2, y2) corner. Alternatively, |
img |
image to draw. It can be either a raster, file name, binary connection or a raw vector containing an image in a common image format such as PNG or JPEG. If it is a raster, then the raster is first encoded into PNG format and passed as raw vector. |
... |
additional arguments that will be passed to
|
plot |
parent plot for the image |
The current implementation uses Java's ImageIO API to read the
image, so the supported formats will depend on your Java
implemetation. Raster objects (i.e., of class "raster",
"nativeRaster"), matrices and arrays) are simply passed to
png::writePNG(img) so for anything other than computationally
constructed objects it is more efficient to use the encoded image.
Resulting iObject.
## very silly example ...
iplot(0:20/20, 0:20/20)
## get a sample image (R logo) from the png package
fn <- system.file("img", "Rlogo.png", package="png")
## put this image behind all points
iraster(0, 0, 1, 1, fn, layer=-2)
## you can use a raster but it's less eficient
## this one goes to the top layer where iObjs reside normally
iraster(0, 0, 0.5, 0.5, png::readPNG(fn))