# Generate a matrix 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, 3.1))
plot_cols(mat2cols(data, col=cols))
heat_legend(data, cols); box(lwd=2)
Run the code above in your browser using DataLab