ximage combines the best of image() and rasterImage().

ximage(
  x,
  extent = NULL,
  zlim = NULL,
  add = FALSE,
  ...,
  xlab = NULL,
  ylab = NULL,
  col = hcl.colors(96, "YlOrRd", rev = TRUE),
  breaks = NULL
)

Arguments

x

matrix, array, or native raster (nativeRaster, or raster)

extent

optional, numeric xmin,xmax,ymin,ymax

zlim

optional, range of data to set colour map (to maintain absolute colours across multiple plots)

add

add to plot, or start afresh

...

passed to plot when add = FALSE

xlab

x axis label, empty by default

ylab

y axis lable, empty by default

col

optional colours to map matrix/array data to

breaks

a set of finite numeric breakpoints for the colours:

Value

a list with 'x' and 'extent' invisibly (extent is the 0,ncol 0,nrow space of the array if not supplied)

Details

ximage() is designed like graphics function with the following limitations removed, image() 1:4, rasterImage() 5:7.

  1. Allow arrays with RGB/A.

  2. Allow matrix with character (named colours, or hex) or raw (Byte) values

  3. Allow list output from vapour, a list with numeric values, hex character, or nativeRaster

  4. Plot in 0,ncol 0,nrow by default

  5. Override default with extent (xmin, xmax, ymin, ymax)

  6. Allow general numeric values.

  7. Start a plot from scratch without setting up a plot to paint to.

  8. Plot by default in 0,ncol,0,nrow if unspecified.

ximage uses the GIS raster default used by rasterImage. WIP: There is a similar function 'image0?' that provides the same features but assumes that orientation is like image...

Colours by 'col' are only mapped for numeric data, this may change (to remap RGB or raw imagery via greyscale conversion)

Examples

ximage(volcano)

ximage(as.raster(matrix(0:1, 49, 56)))