Learn R Programming

IMIFA (version 1.3.1)

heat_legend: Add a colour key legend to heatmap plots

Description

Using only base graphics, this function appends a colour key legend for heatmaps produced by, for instance, plot_cols or image.

Usage

heat_legend(data, cols)

Arguments

data

Either the data with which the heatmap was created or a vector containing its minimum and maximum values. Missing values are ignored.

cols

The palette used when the heatmap was created.

Value

Modifies an existing plot by adding a legend.

See Also

image, plot_cols, mat2cols, is.cols

Examples

Run this code
# NOT RUN {
# Generate a matrix, flip it, and plot it with a legend
data <- matrix(rnorm(50), nrow=10, ncol=5)
cols <- heat.colors(12)[12:1]
par(mar=c(5.1, 4.1, 4.1, 4.1))

image(t(data)[,nrow(data):1], col=cols)
heat_legend(data, cols); box(lwd=2)
# }

Run the code above in your browser using DataLab