add_image {recolorize} | R Documentation |
Add a raster image to a plot
Description
Adds a raster image (a 3D array) to an existing plot as an image. A silly, generic function, but nice for visualization. Sort of like graphics::points, but for images.
Usage
add_image(obj, x = NULL, y = NULL, width = NULL, interpolate = TRUE, angle = 0)
Arguments
obj |
An array of the dimensions height x width x channels,
such as read in by png::readPNG or readImage, or the |
x , y |
The x and y coordinates on which the image should be centered. |
width |
Image width, in x-axis units. |
interpolate |
Passed to graphics::rasterImage. Use linear interpolation when scaling the image? |
angle |
Passed to graphics::rasterImage. The angle (in degrees) for rotating the image. |
Value
Nothing; adds an image to the existing plot window.
Examples
images <- dir(system.file("extdata", package = "recolorize"),
".png", full.names = TRUE)
x <- runif(5)
y <- runif(5)
plot(x, y,
xlim = range(x) + c(-0.2, 0.2),
ylim = range(y) + c(-0.2, 0.2))
for (i in 1:length(images)) {
img <- readImage(images[i])
add_image(img, x[i], y[i], width = 0.1)
}
[Package recolorize version 0.1.0 Index]