Improved version of the image
function in the graphics
package. In particular,
it displays matrices the way they are shown in the R
console, not transposed/rearranged/... For example, a
covariance matrix has the diagonal in from topleft to
bottomright as it should be, and not from bottomleft to
topright.
The function make_legend
also provides a
better color scale legend handling.
Optionally image2
displays a color histogram below
the image, which can be used to refine the display of a
matrix by trimming outliers (as they can often distort
the color representation).
1 2 3 4 5 6  image2(x = NULL, y = NULL, z = NULL, col = NULL, axes = FALSE, legend = TRUE,
xlab = "", ylab = "", zlim = NULL, density = FALSE, max.height = NULL,
zlim.label = "color scale", ...)
make_legend(data = NULL, col = NULL, side = 1, zlim = NULL, col.ticks = NULL,
cex.axis = 2, max.height = 1, col.label = "")

x,y 
locations of grid lines at which the values in
z are measured. These must be finite, nonmissing and in
(strictly) ascending order. By default, equally spaced
values from 0 to 1 are used. If x is a list, its
components 
z 
a matrix containing the values to be plotted
(NAs are allowed). Note that 
col 
colors: either a string decribing a pallette
from the 
axes 
a logical value indicating whether both axes should be drawn on the plot. 
xlab 
a label for the x axis 
ylab 
a label for the y axis 
legend 
logical; if 
zlim 
minimum and maximum z values for which colors
should be plotted, defaulting to the range of the finite
values of 
zlim.label 
character string (default: 
density 
logical; if 
max.height 
height of the density plot (typically not modified by user) 
... 
optional arguments passed to

data 
data for which the legend should be plotted 
side 
on which side of the plot (1=bottom, 2=left, 3=top, 4=right) 
col.ticks 
color tick marks 
cex.axis 
The magnification to be used for axis
annotation relative to the current setting of

col.label 
same as 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  ## Not run:
# Correlation matrix
data(iris) # make sure its from 'datasets' package, not from 'locfit'
image(cor(as.matrix(iris[, names(iris) != "Species"])))
# Correlation matrix has diagonal from top left to bottom right
par(mar = c(1, 3, 1, 2))
image2(cor(as.matrix(iris[, names(iris) != "Species"])), col = "RdBu", axes = FALSE)
## End(Not run)
# Color histogram
nn < 10
set.seed(nn)
AA < matrix(sample(c(rnorm(nn^2, 1, 0.1), rexp(nn^2/2, 0.5))), ncol = nn)
image2(AA, col = "Spectral")
image2(y = 1:15 + 2, x = 1:10, AA, col = "Spectral", axes = TRUE)
image2(y = 1:15 + 2, x = 1:10, AA, col = "Spectral", density = TRUE, axes = TRUE)
image2(AA, col = "Spectral", density = TRUE, zlim = c(min(AA), 3))

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.