clines                package:clines                R Documentation

_C_a_l_c_u_l_a_t_e _C_o_n_t_o_u_r _L_i_n_e_s

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

     Produces a list of contours.  Each contour is a list of 3
     elements: the contour level, the x-coordinates of the contour, and
     the y-coordinates of the contour.

_U_s_a_g_e:

     clines(x, y, z, nlevels = 10, levels = pretty(range(z, na.rm = TRUE), nlevels))

_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.

 nlevels: number of contour levels desired *iff* 'levels' is not
          supplied.

  levels: numeric vector of levels at which to draw contour lines.

_V_a_l_u_e:

     A list of contours. Each contour consists of: 

      1 : The contour level.

      2 : The x-coordinates of the contour.

      3 : The y-coordinates of the contour.

_W_a_r_n_i_n_g:

     This function was just a temporary interface to the C code
     underlying the 'contour' function.  There is now a base function
     called 'contourLines' which should be used instead.

_A_u_t_h_o_r(_s):

     Paul Murrell

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

     # Mount Maungawhau
     data("volcano")
     rx <- range(x <- 10*1:nrow(volcano))
     ry <- range(y <- 10*1:ncol(volcano))
     ry <- ry + c(-1,1) * (diff(rx) - diff(ry))/2
     tcol <- terrain.colors(12)
     plot(x = 0, y = 0,type = "n", xlim = rx, ylim = ry, xlab = "", ylab = "")
     u <- par("usr")
     rect(u[1], u[3], u[2], u[4], col = tcol[8], border = "red")

     line.list <- clines(x, y, volcano)

     contour(x, y, volcano, col = tcol[2], lty = "solid", add = TRUE,
             vfont = c("sans serif", "plain"))

     templines <- function(clines) {
       lines(clines[[2]], clines[[3]])
     }  
     invisible(lapply(line.list, templines))

