plotMatrix: Plot a matrix.

plotMatrixR Documentation

Plot a matrix.

Description

'plotMatrix' plots a matrix, decorated with the names of rows and columns, and, if requested, with lines separating specified rows/columns. Also, a legend gets drawn, by default.

Usage

plotMatrix(x, col = gray.colors(16), 
    transpose = FALSE, 
    axes = c(2, 3), legend = TRUE, 
    legend.width = 0.2, 
    legend.nlevels = length(col) + 
        1, main = NULL, 
    rowDelim = NULL, 
    rowDelimCol = "black", 
    colDelim = NULL, 
    colDelimCol = "black", 
    useRaster = NULL)

Arguments

x

a matrix

col

colors

transpose

transpose the matrix?

axes

which axes (sides of the matrix) to annotate? (1=below, 2=left, 3=above and 4=right).

legend

draw legend?

legend.width

the relative width of the legend to the total width of the plot

legend.nlevels

number of levels in the legend (defaults to the number of colors in 'col')

main

main

rowDelim

an optional vector of rows after which to put a separation line

rowDelimCol

the color of the row separation line

colDelim

an optional vector of columns after which to put a separation line

colDelimCol

the color of the column separation line

useRaster

if TRUE, the matrix gets plotted as a raster image, not as rectangles (the latter sometimes leads to antialising artifacts), see image())

Author(s)

Tomas Sieger

Examples

x<-matrix(1:36,6)
rownames(x)<-paste('row',1:6)
colnames(x)<-paste('column',1:6)
x
plotMatrix(x)

# group rows and columns
x<-repmat(matrix(3-c(1,2,1,2,3,2,1,2,1),3),3,3)
plotMatrix(x, rowDelim = c(3,6), colDelim = c(3,6), colDelimCol='red')

tsieger/tsiMisc documentation built on Oct. 10, 2023, 10:24 p.m.