plot.matrix: Visualize a Matrix of Numeric Values

View source: R/util.R

plot.matrixR Documentation

Visualize a Matrix of Numeric Values

Description

This method draws a heat map to demonstrate a numeric matrix, using gplots::heatmap.2 as the underlying engine. Note that the method retains the original (unscaled) values in the matrix, as well as the orders of rows and columns of the matrix.

Usage

## S3 method for class 'matrix'
plot(
  x,
  breaks = 101,
  symbreaks = FALSE,
  col = NULL,
  low = "blue",
  mid = "white",
  high = "red",
  na.color = "black",
  lmat = NULL,
  ...
)

Arguments

x

The matrix of numeric values to be plotted.

breaks

Either a numeric vector indicating the splitting points for binning x into colors, or an integer number of break points to be used, in which case the break points will be spaced equally across the data range.

symbreaks

Logical value indicating whether the break points should be made symmetric about 0. Ignored if breaks is specified as a numeric vector.

col

Colors used for the heat map. Must have a length equal to the number of break points minus 1. By default, colors are generated by colorpanel.

low, mid, high

Arguments to be passed to colorpanel to generate colors. Ignored if col is explicitly specified. Note that setting mid to NA suppresses the usage of this argument.

na.color

Color to be used for missing (NA) values.

lmat

Position matrix for the layout of color key and heat map. To be passed to heatmap.2. By default, the color key lies above the heat map.

...

Further arguments to be passed to heatmap.2.

Value

The value returned from heatmap.2.

See Also

colorpanel for generating a sequence of colors that varies smoothly; heatmap.2 for drawing a heat map.

Examples

set.seed(17)
x <- matrix(rnorm(30, sd = 2), nrow = 5)
x[2, 5] <- NA

# Use the default setting.
plot(x)

# Use break points symmetric about 0.
plot(x, symbreaks = TRUE)


MAnorm2 documentation built on Oct. 29, 2022, 1:12 a.m.