Learn R Programming

popbio (version 2.7)

image2: Display a matrix image

Description

Creates a grid of colored rectangles to display a projection, elasticity, sensitivity or other matrix.

Usage

image2(x, col = c("white", rev(heat.colors(23))), breaks, log = TRUE,
  border = NA, box.offset = 0.1, round = 3, cex, text.cex = 1,
  text.col = "black", mar = c(1, 3, 3, 1), labels = 2:3,
  label.offset = 0.1, label.cex = 1, srt = 90)

Value

A image plot of the matrix

Arguments

x

A numeric matrix with row and column names

col

A vector of colors for boxes

breaks

A numeric vector of break points or number of intervals into which x is to be cut. Default is the length of col

log

Cut values in x using a log scale, default TRUE

border

The border color for boxes, default is no borders

box.offset

Percent reduction in box size (a number between 0 and 1), default is 10% reduction

round

Number of decimal places to display values of x in each box

cex

Magnification size of text and labels, if specified this will replace values in both text.cex and label.cex

text.cex

Magnification size of text in cells only

text.col

Color of text in cells, use NA to skip text labels

mar

Margins on four sides of plot

labels

A vector giving sides of the plot (1=bottom, 2=left, 3=top, 4=right) for row and column labels

label.offset

Amount of space between label and boxes

label.cex

Magnification size of labels

srt

String rotation for labels on top and bottom of matrix

Author

Chris Stubben

See Also

Examples

Run this code
A <- calathea[[11]]
op <- par(mfrow=c(2,2))
image2(A, text.cex=.8)
## with  gray border and labels on bottom right
image2( A, text.cex=.8, border="gray70", labels=c(1,4), mar=c(3,1,1,3))
## no text or box offset
image2( A, box.offset=0, text.col=NA)
# set zeros to NA to print everything but zero
A[A == 0] <- NA
image2( A, box.offset=0 , text.cex=.8)
## if comparing two or more matrices, get the log10 range
## of values (not including zero) and pass to breaks
x <- unlist(calathea[-17])
x <- log10(range(x[x!=0]))
par(mfrow=c(4,4))
for(i in 1:16){
  A <- calathea[[i]]
  A[A == 0] <- NA
  image2(A, cex=.7, box.offset=0, breaks=seq(x[1], x[2], len=24))
    title(names(calathea[i]), line=3)
}
par(op)

Run the code above in your browser using DataLab