levelplot              package:lattice              R Documentation

_L_e_v_e_l _p_l_o_t_s _a_n_d _c_o_n_t_o_u_r _p_l_o_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Draw Level Plots and Contour plots.

_U_s_a_g_e:

     levelplot(x, data, ...)
     contourplot(x, data, ...)

     ## S3 method for class 'formula':
     levelplot(x,
               data,
               allow.multiple = is.null(groups) || outer,
               outer = TRUE,
               aspect = "fill",
               panel = lattice.getOption("panel.levelplot"),
               prepanel = NULL,
               scales = list(),
               strip = TRUE,
               groups = NULL,
               xlab,
               xlim,
               ylab,
               ylim,
               at,
               cuts = 15,
               pretty = FALSE,
               region = TRUE,
               drop.unused.levels = lattice.getOption("drop.unused.levels"),
               ...,
               lattice.options = NULL,
               default.scales = list(),
               colorkey = region,
               col.regions,
               alpha.regions,
               subset = TRUE)

     ## S3 method for class 'formula':
     contourplot(x,
                 data,
                 panel = lattice.getOption("panel.contourplot"),
                 cuts = 7,
                 labels = TRUE,
                 contour = TRUE,
                 pretty = TRUE,
                 region = FALSE,
                 ...)

     ## S3 method for class 'table':
     levelplot(x, data = NULL, aspect = "iso", ...,
               xlim, ylim, row.values, column.values)

     ## S3 method for class 'table':
     contourplot(x, data = NULL, aspect = "iso", ...,
                 xlim, ylim, row.values, column.values)

     ## S3 method for class 'matrix':
     levelplot(x, data = NULL, xlab, ylab, ...)

     ## S3 method for class 'matrix':
     contourplot(x, data = NULL, xlab, ylab, ...)

     ## S3 method for class 'array':
     levelplot(x, data = NULL, ...)

     ## S3 method for class 'array':
     contourplot(x, data = NULL, ...)

_A_r_g_u_m_e_n_t_s:

       x: for the 'formula' method, a formula of the form 'z ~ x * y |
          g1 * g2 * ...', where 'z' is a numeric response, and 'x', 'y'
          are numeric values evaluated on a rectangular grid.  'g1, g2,
          ...' are optional conditional variables, and must be either
          factors or shingles if present.

          Calculations are based on the assumption that all x and y
          values are evaluated on a grid (defined by their unique
          values). The function will not return an error if this is not
          true, but the display might not be meaningful.  However, the
          x and y values need not be equally spaced.

          Both 'levelplot' and 'wireframe' have methods for 'matrix',
          'array', and 'table' objects, in which case 'x' provides the
          'z' vector described above, while its rows and columns are
          interpreted as the 'x' and 'y' vectors respectively.  This is
          similar to the form used in 'filled.contour' and 'image'. 
          For higher-dimensional arrays and tables, further dimensions
          are used as conditioning variables.  Note that the dimnames
          may be duplicated; this is handled by calling 'make.unique'
          to make the names unique (although the original labels are
          used for the x- and y-axes). 

    data: For the 'formula' methods, an optional data frame in which
          variables in the formula (as well as 'groups' and 'subset',
          if any) are to be evaluated.  Usually ignored with a warning
          in other cases. 

row.values, column.values: Optional vectors of values that define the
          grid when 'x' is a matrix.  'row.values' and 'column.values'
          must have the same lengths as 'nrow(x)' and 'ncol(x)'
          respectively.  By default, row and column numbers. 

   panel: panel function used to create the display, as described in
          'xyplot' 

  aspect: For the 'matrix' methods, the default aspect ratio is chosen
          to make each cell square.  The usual default is
          'aspect="fill"', as described in 'xyplot'. 

      at: numeric vector giving breaks along the range of 'z'. Contours
          (if any) will be drawn at these heights, and the regions in
          between would be colored using 'col.regions'. 

col.regions: color vector to be used if regions is TRUE. The general
          idea is that this should be a color vector of moderately
          large length (longer than the number of regions. By default
          this is 100). It is expected that this vector would be
          gradually varying in color (so that nearby colors would be
          similar). When the colors are actually chosen, they are
          chosen to be equally spaced along this vector. When there are
          more regions than col.regions, the colors are recycled. 

alpha.regions: numeric, specifying alpha transparency (works only on
          some devices) 

colorkey: logical specifying whether a color key is to be drawn
          alongside the plot, or a list describing the color key. The
          list may contain the following components:



          '_s_p_a_c_e': location of the colorkey, can be one of '"left"',
               '"right"', '"top"' and '"bottom"'.  Defaults to
               '"right"'.


          '_x', '_y': location, currently unused 

          '_c_o_l': vector of colors 

          '_a_t': numeric vector specifying where the colors change. must
               be of length 1 more than the col vector.


          '_l_a_b_e_l_s': a character vector for labelling the 'at' values,
               or more commonly, a list describing characteristics of
               the labels.  This list may include components 'labels',
               'at', 'cex', 'col', 'rot', 'font', 'fontface' and
               'fontfamily'.


          '_t_i_c_k._n_u_m_b_e_r': approximate number of ticks. 

          '_c_o_r_n_e_r': interacts with x, y; unimplemented 

          '_w_i_d_t_h': width of the key 

          '_h_e_i_g_h_t': length of key w.r.t side of plot. 

 contour: logical, whether to draw contour lines. 

    cuts: number of levels the range of 'z' would be divided into 

  labels: typically a logical indicating whether contour lines should
          be labelled, but other possibilities for more sophisticated
          control exists.  Details are documented in the help page for
          'panel.levelplot', to which this argument is passed on
          unchanged.  That help page also documents the 'label.style'
          argument, which affects how the labels are rendered. 

  pretty: logical, whether to use pretty cut locations and labels 

  region: logical, whether regions between contour lines should be
          filled 

allow.multiple, outer, prepanel, scales, strip, groups, xlab,
xlim, ylab, ylim, drop.unused.levels, lattice.options,
default.scales, subset: 
          these arguments are described in the help page for 'xyplot'. 

     ...: other arguments.  Some are processed by 'levelplot' or
          'contourplot', and those unrecognized are passed on to the
          panel function.  

_D_e_t_a_i_l_s:

     These and all other high level Trellis functions have several
     arguments in common. These are extensively documented only in the
     help page for 'xyplot', which should be consulted to learn more
     detailed usage.

     Other useful arguments are mentioned in the help page for the
     default panel function 'panel.levelplot' (these are formally
     arguments to the panel function, but can be specified in the high
     level calls directly).

_V_a_l_u_e:

     An object of class '"trellis"'. The 'update' method can be used to
     update components of the object and the 'print' method (usually
     called by default) will plot it on an appropriate plotting device.

_A_u_t_h_o_r(_s):

     Deepayan Sarkar Deepayan.Sarkar@R-project.org

_R_e_f_e_r_e_n_c_e_s:

     Sarkar, Deepayan (2008) "Lattice: Multivariate Data Visualization
     with R", Springer. <URL: http://lmdvr.r-forge.r-project.org/>

_S_e_e _A_l_s_o:

     'xyplot', 'Lattice', 'panel.levelplot'

_E_x_a_m_p_l_e_s:

     x <- seq(pi/4, 5 * pi, length = 100)
     y <- seq(pi/4, 5 * pi, length = 100)
     r <- as.vector(sqrt(outer(x^2, y^2, "+")))
     grid <- expand.grid(x=x, y=y)
     grid$z <- cos(r^2) * exp(-r/(pi^3))
     levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="",
               ylab="", main="Weird Function", sub="with log scales",
               colorkey = FALSE, region = TRUE)

     #S-PLUS example
     require(stats)
     attach(environmental)
     ozo.m <- loess((ozone^(1/3)) ~ wind * temperature * radiation,
            parametric = c("radiation", "wind"), span = 1, degree = 2)
     w.marginal <- seq(min(wind), max(wind), length = 50)
     t.marginal <- seq(min(temperature), max(temperature), length = 50)
     r.marginal <- seq(min(radiation), max(radiation), length = 4)
     wtr.marginal <- list(wind = w.marginal, temperature = t.marginal,
             radiation = r.marginal)
     grid <- expand.grid(wtr.marginal)
     grid[, "fit"] <- c(predict(ozo.m, grid))
     contourplot(fit ~ wind * temperature | radiation, data = grid,
                 cuts = 10, region = TRUE,
                 xlab = "Wind Speed (mph)",
                 ylab = "Temperature (F)",
                 main = "Cube Root Ozone (cube root ppb)")
     detach()

