JPlotRaster: Adds a raster image to a plot, preserving the image's aspect...

View source: R/raster.R

JPlotRasterR Documentation

Adds a raster image to a plot, preserving the image's aspect ratio.

Description

Exactly one of width and height must be specified.

Usage

JPlotRaster(
  img,
  x,
  y,
  width = NA,
  height = NA,
  position = c("centre", "center", "bottomright", "bottom", "bottomleft", "left",
    "topleft", "top", "topright", "right"),
  offset = c(0, 0),
  ...
)

Arguments

img

Raster image, possibly created by calling readJPEG or readPNG.

x, y

Location on the plot of the image in user coordinates.

width

Width of the image in user coordinates. The height will be calculated from the aspect ratio of the image and the respective scales of the x- and y-axes.

height

Height of the image in user coordinates. The width will be calculated from the aspect ratio of the image and the respective scales of the x- and y-axes.

position

Specifies the location of x, y on the image. E.g. if "centre", the image will be centred on x, y. if "topleft", the top left-hand corner of the image will be located at x, y.

offset

Vector with length 2. Amount to offset x and y by, as a proportion of the image display width and height, respectively.

...

Additional arguments are passed on to rasterImage.

Examples

## Not run: 
plot(...)
img <- readJPEG("myjpeg.jpg", native = TRUE)
# Draw image centred on (0, 0)
JPlotRaster(img, x = 0, y = 0, width = 2)

## End(Not run)


JimMcL/JUtils documentation built on Nov. 7, 2024, 11:25 a.m.