| image {base} | R Documentation |
Display a Color Image
Description
Creates a grid of colored or gray-scale rectangles with colors
corresponding to the values in z. This can be used to display
three-dimensional or spatial data aka “images”.
This is a generic function.
The functions heat.colors, terrain.colors
and topo.colors create heat-spectrum (red to white) and
topographical color schemes suitable for displaying ordered data, with
n giving the number of colors desired.
Usage
image(x, ...)
image.default(x, y, z, zlim, xlim, ylim, col = heat.colors(12),
add = FALSE, xaxs = "i", yaxs = "i", xlab, ylab,
breaks, oldstyle = FALSE, ...)
Arguments
x, y |
locations of grid lines at which the values in |
z |
a matrix containing the values to be plotted ( |
zlim |
the minimum and maximum |
xlim, ylim |
ranges for the plotted |
col |
a list of colors such as that generated by
|
add |
logical; if |
xaxs, yaxs |
style of x and y axis. The default |
xlab, ylab |
each a character string giving the labels for the x and
y axis. Default to the ‘call names’ of |
breaks |
a set of breakpoints for the colours: must give one more breakpoint than colour. |
oldstyle |
logical. If true the midpoints of the colour intervals
are equally spaced, and |
... |
graphical parameters for |
Details
The length of x should be equal to the nrow(x)+1 or
nrow(x). In the first case x specifies the boundaries
between the cells: in the second case x specifies the
midpoints of the cells. Similar reasoning applies to y. It
probably only makes sense to specify the midpoints of an
equally-spaced grid. If you specify just one row or column and a
length-one x or y, the whole user area in the
corresponding direction is filled.
If breaks is specified then zlim is unused and the
algorithm used follows cut, so intervals are closed on
the right and open on the left except for the lowest interval.
Note
Based on a function by Thomas Lumley tlumley@u.washington.edu.
See Also
contour,
heat.colors, topo.colors,
terrain.colors, rainbow,
hsv, par.
Examples
x <- y <- seq(-4*pi, 4*pi, len=27)
r <- sqrt(outer(x^2, y^2, "+"))
image(z = z <- cos(r^2)*exp(-r/6), col=gray((0:32)/32))
image(z, axes = FALSE, main = "Math can be beautiful ...",
xlab = expression(cos(r^2) * e^{-r/6}))
contour(z, add = TRUE, drawlabels = FALSE)
data(volcano)
x <- 10*(1:nrow(volcano))
y <- 10*(1:ncol(volcano))
image(x, y, volcano, col = terrain.colors(100), axes = FALSE)
contour(x, y, volcano, levels = seq(90, 200, by=5), add = TRUE, col = "peru")
axis(1, at = seq(100, 800, by = 100))
axis(2, at = seq(100, 600, by = 100))
box()
title(main = "Maunga Whau Volcano", font.main = 4)