savemat {squash} | R Documentation |
Save a matrix as a raster image file
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
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 |
outlier |
(Optional) A color for outliers, if |
dev |
Which graphics device to use. |
... |
Further arguments passed to the graphics device; see |
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
## 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)