savemat: Save a matrix as a raster image file

Description Usage Arguments Details Value See Also Examples

View source: R/squash.R

Description

Save a matrix as a PNG, TIFF, BMP, JPEG, or PDF image file, such that each pixel corresponds to exactly one element of the matrix.

Usage

1
2
3
savemat(x, filename, map = NULL, outlier = NULL,
       dev = c('png', 'pdf', 'bmp', 'tiff', 'jpeg'), 
       do.dev.off = TRUE, ...)

Arguments

x

A matrix

filename

Filename

map

(Optional) a list, as generated by makecmap.

outlier

(Optional) A color for outliers, if map is specified.

dev

Which graphics device to use.

...

Further arguments passed to the graphics device; see png or pdf.

do.dev.off

Close graphics device when finished?

Details

This function is a relatively simple wrapper around the usual graphics device with the same name as dev. The idea is to provide an easy way of creating an image file from a matrix, without axes, plotting frame, labels, etc.

For all choices of dev except "pdf", the output image dimensions are set to match the matrix size, such that each pixel corresponds to an element of the matrix.

If map is NULL (the default), the matrix is interpreted as a matrix of colors.

If map is specified, it is used to translate the numeric matrix x into a matrix of colors, using cmap.

Value

None.

See Also

cimage for drawing a matrix on the screen.

Examples

1
2
3
4
5
6
7
8
9
  
## Not run: 
  big.color.matrix <- matrix(rep(colors()[1:625], 16), nrow = 100)
  
  ## save as a PNG
  savemat(big.color.matrix, file = 'test.png')


## End(Not run)

squash documentation built on Feb. 20, 2020, 9:08 a.m.