image-methods {Matrix} | R Documentation |
Methods for function image
in package
Matrix. An image of a matrix simply color codes all matrix
entries and draws the n x m matrix using an
n x m grid of (colored) rectangles.
## S4 method for signature 'dgTMatrix' image(x, xlim = .5 + c(0, di[2]), ylim = .5 + c(di[1], 0), aspect = "iso", sub = sprintf("Dimensions: %d x %d", di[1], di[2]), xlab = "Column", ylab = "Row", cuts = 15, useRaster = FALSE, useAbs = NULL, colorkey = !useAbs, col.regions = NULL, lwd = NULL, ...)
x |
a Matrix object, i.e., fulfilling
|
xlim, ylim |
x- and y-axis limits; may be used to “zoom into” matrix. |
aspect |
aspect ratio specified as number (y/x) or string;
see |
sub, xlab, ylab |
axis annotation with sensible defaults;
see |
cuts |
number of levels the range of matrix values would be divided into. |
useRaster |
logical indicating if raster graphics should be used
(instead of the tradition rectangle vector drawing). If true,
Note that using raster graphics may often be faster, but can be slower, depending on the matrix dimensions and the graphics device (dimensions). |
useAbs |
logical indicating if |
colorkey |
logical indicating if a color key aka ‘legend’
should be produced. Default is to draw one, unless |
col.regions |
vector of gradually varying colors; see
|
lwd |
non-negative number or |
... |
further arguments passed to methods and
|
All methods currently end up calling the method for the
dgTMatrix
class.
Use showMethods(image)
to list them all.
showMethods(image) ## If you want to see all the methods' implementations: showMethods(image, incl=TRUE, inherit=FALSE) data(CAex) image(CAex, main = "image(CAex)") image(CAex, useAbs=TRUE, main = "image(CAex, useAbs=TRUE)") cCA <- Cholesky(crossprod(CAex), Imult = .01) image(cCA, main="Cholesky(crossprod(CAex), Imult = .01)") image(cCA, useAbs=TRUE) data(USCounties) image(USCounties)# huge image(sign(USCounties))## just the pattern # how the result looks, may depend heavily on # the device, screen resolution, antialiasing etc # e.g. x11(type="Xlib") may show very differently than cairo-based ## Drawing borders around each rectangle; # again, viewing depends very much on the device: image(USCounties[1:400,1:200], lwd=.1) image(USCounties[1:200,1:200], lwd=.5) image(USCounties[1:200,1:200], lwd=.01) ## Using raster graphics: For PDF this would give a 77 MB file, ## however, for such a large matrix, this is typically considerably ## *slower* (than vector graphics rectangles) in most cases : if(doPNG <- !dev.interactive()) png("image-USCounties-raster.png", width=3200, height=3200) image(USCounties, useRaster = TRUE) # should not suffer from anti-aliasing if(doPNG) dev.off() ## and now look at the *.png image in a viewer you can easily zoom in and out