pchImage: Images as plotting characters

View source: R/pchimage.R

pchImageR Documentation

Images as plotting characters

Description

pchimage returns a plot that displays an image. It allows users to directly include a .png or a .jpeg file in a plot region.

Usage

pchImage(
  x,
  y,
  obj = NULL,
  file = NULL,
  cex.x = 1,
  cex.y = cex.x,
  atcenter = TRUE,
  add = TRUE,
  col = NULL,
  ...
)

Arguments

x

the x coordinates of images to be drawn.

y

the y coordinates of images to be drawn.

obj

an object of class nativeRaster.

file

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

cex.x

a numerical value giving the amount by which the horizontal width of the image should be magnified, a value of 1 means 5% of the total width.

cex.y

Same as cex.x for the y axis.

atcenter

a logical. If TRUE them x and y coordinates describe the center of the image. Otherwise they represent the bottom-left coordinates of the image.

add

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

col

optional color use to fill pixels whose values are not 0.

...

Additional arguments to be passed to the rasterImage function.

Details

Either obj or file must be defined. If file is not null, then png::readPNG() or jpeg::readJPEG() according to the end of the file extension.

Examples

# Example:
img <- png::readPNG(system.file('img', 'Rlogo.png', package='png'), native=TRUE)
n<-15
plot0(c(0,1),c(0,1))
pchImage(0.1+0.8*stats::runif(n), 0.1+0.8*stats::runif(n), cex.x=0.2+1.6*stats::runif(n),
obj=img, angle=360*runif(n), col=2)

KevCaz/graphicsutils documentation built on Sept. 16, 2022, 10:05 a.m.