

image {base}                                 R Documentation

_D_i_s_p_l_a_y _a _C_o_l_o_r _I_m_a_g_e

_D_e_s_c_r_i_p_t_i_o_n_:

     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''.

     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.

_U_s_a_g_e_:

     image(x, y, z, zlim, col = heat.colors(12),
           add = FALSE, xaxs = "i", yaxs = "i", xlab, ylab, ...)

_A_r_g_u_m_e_n_t_s_:

     x,y: locations of grid lines at which the values in `z'
          are measured.  These must be in ascending order.
          By default, equally spaced values from 0 to 1 are
          used.  If `x' is a `list', its components `x$x'
          and `x$y' are used for `x' and `y', respectively.
          If the list has component `z' this is used for
          `z'.

       z: a matrix containing the values to be plotted
          (`NA's are allowed).  Note that `x' can be used
          instead of `z' for convenience.

    zlim: the minimum and maximum `z' values for which col-
          ors will be plotted.  Each of the given colors
          will be used to color an equispaced interval of
          this range.

     col: a list of colors such as that generated by `rain-
          bow', `heat.colors', `topo.colors', `terrain.col-
          ors' or similar functions.

     add: logical; if `TRUE', add to current plot (and dis-
          regard the following arguments).  This is rarely
          useful because `image' ``paints'' over existing
          graphics.

xaxs, yaxs: style of x and y axis.  The default `"i"' is
          appropriate for images.  See `par'.

xlab, ylab: each a character string giving the labels for
          the x and y axis.  Default to the `call names' of
          `x' or `y', or to `""' if these where unspecified.

     ...: graphical parameters for `plot' may also be passed
          as arguments to this function.

_D_e_t_a_i_l_s_:

     The length of `x' should be equal to the `nrow(x)+1' or
     `nrow(x)'. In the first case `x' specifies the bound-
     aries between the cells: in the second case `x' speci-
     fies 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.

_N_o_t_e_:

     Based on a function by Thomas Lumley thomas@bio-
     stat.washington.edu.

_S_e_e _A_l_s_o_:

     `contour', `heat.colors', `topo.colors', `terrain.col-
     ors', `rainbow', `hsv', `par'.

_E_x_a_m_p_l_e_s_:

     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=F, main="Math can be beautiful ...",
           xlab=expression(cos(r^2) * e^{-r/6}))
     contour(z, add=T)

     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)

