levelplot(x, data, ...)
contourplot(x, data, ...)
"levelplot"(x, data, allow.multiple = is.null(groups) || outer, outer = TRUE, aspect = "fill", panel = if (useRaster) lattice.getOption("panel.levelplot.raster") else 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"), ..., useRaster = FALSE, lattice.options = NULL, default.scales = list(), default.prepanel = lattice.getOption("prepanel.default.levelplot"), colorkey = region, col.regions, alpha.regions, subset = TRUE)
"contourplot"(x, data, panel = lattice.getOption("panel.contourplot"), default.prepanel = lattice.getOption("prepanel.default.contourplot"), cuts = 7, labels = TRUE, contour = TRUE, pretty = TRUE, region = FALSE, ...)
"levelplot"(x, data = NULL, aspect = "iso", ..., xlim, ylim)
"contourplot"(x, data = NULL, aspect = "iso", ..., xlim, ylim)
"levelplot"(x, data = NULL, aspect = "iso", ..., xlim, ylim, row.values = seq_len(nrow(x)), column.values = seq_len(ncol(x)))
"contourplot"(x, data = NULL, aspect = "iso", ..., xlim, ylim, row.values = seq_len(nrow(x)), column.values = seq_len(ncol(x)))
"levelplot"(x, data = NULL, ...)
"contourplot"(x, data = NULL, ...)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).
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.
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. xyplot
matrix methods, the default aspect ratio is chosen to
make each cell square. The usual default is aspect="fill",
as described in xyplot.
z. Contours (if any) will be drawn at these heights, and the
regions in between would be colored using col.regions. In
the latter case, values outside the range of at will not be
drawn at all. This serves as a way to limit the range of the data
shown, similar to what a zlim argument might have been used
for. However, this also means that when supplying at
explicitly, one has to be careful to include values outside the
range of z to ensure that all the data are shown. at can have length one only if region=FALSE.
col.regions, the colors are recycled. The actual color
assignment is performed by level.colors, which is
documented separately.
space:"left",
"right", "top" and "bottom". Defaults to
"right".
x, y:
col:col.regions
argument in level.colors
at:
labels: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.
tick.number:
tck:
corner:
width:
height:
raster:grid.raster. See also
panel.levelplot.raster.
interpolate:rasterGrob when raster=TRUE.
axis.line:trellis.par.get("axis.line").
axis.text:trellis.par.get("axis.text").
z would be divided into.
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.
xyplot.
xyplot.
levelplot or contourplot, and those that are
unrecognized are passed on to the panel function.
TRUE changes the default panel
function from panel.levelplot to
panel.levelplot.raster, and sets the default value of
colorkey$raster to TRUE.
Note that panel.levelplot.raster provides only a
subset of the features of panel.levelplot, but setting
useRaster=TRUE will not check whether any of the additional
features have been requested. Not all devices support raster images. For devices that appear to
lack support, useRaster=TRUE will be ignored with a warning.
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).
Sarkar, Deepayan (2008) Lattice: Multivariate Data Visualization with R, Springer. http://lmdvr.r-forge.r-project.org/
xyplot, Lattice,
panel.levelplot
x <- seq(pi/4, 5 * pi, length.out = 100)
y <- seq(pi/4, 5 * pi, length.out = 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.out = 50)
t.marginal <- seq(min(temperature), max(temperature), length.out = 50)
r.marginal <- seq(min(radiation), max(radiation), length.out = 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()
Run the code above in your browser using DataLab