Description Usage Arguments Details Author(s) See Also Examples
These are predefined panel functions available in lattice for use in constructing new panel functions (often onthefly).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42  panel.abline(a = NULL, b = 0,
h = NULL, v = NULL,
reg = NULL, coef = NULL,
col, col.line, lty, lwd, alpha, type,
...,
reference = FALSE,
identifier = "abline")
panel.refline(...)
panel.curve(expr, from, to, n = 101,
curve.type = "l",
col, lty, lwd, type,
...,
identifier = "curve")
panel.rug(x = NULL, y = NULL,
regular = TRUE,
start = if (regular) 0 else 0.97,
end = if (regular) 0.03 else 1,
x.units = rep("npc", 2),
y.units = rep("npc", 2),
col, col.line, lty, lwd, alpha,
...,
identifier = "rug")
panel.average(x, y, fun = mean, horizontal = TRUE,
lwd, lty, col, col.line, type,
...,
identifier = "linejoin")
panel.linejoin(x, y, fun = mean, horizontal = TRUE,
lwd, lty, col, col.line, type,
...,
identifier = "linejoin")
panel.fill(col, border, ..., identifier = "fill")
panel.grid(h=3, v=3, col, col.line, lty, lwd, x, y, ..., identifier = "grid")
panel.lmline(x, y, ..., identifier = "lmline")
panel.mathdensity(dmath = dnorm, args = list(mean=0, sd=1),
n = 50, col, col.line, lwd, lty, type,
..., identifier = "mathdensity")

x, y 
Variables defining the contents of the panel.
In 
a, b 
Coefficients of the line to be added by

coef 
Coefficients of the line to be added as a vector of length 2. 
reg 
A (linear) regression object, with a 
h, v 
For For If 
reference 
A logical flag determining whether the default
graphical parameters for 
expr 
An expression considered as a function of 
n 
The number of points to use for drawing the curve. 
from, to 
optional lower and upper xlimits of curve. If missing, limits of current panel are used 
curve.type 
Type of curve ( 
regular 
A logical flag indicating whether the ‘rug’ is to be drawn on the ‘regular’ side (left / bottom) or not (right / top). 
start, end 
endpoints of rug segments, in normalized parent
coordinates (between 0 and 1). Defaults depend on value of

x.units, y.units 
Character vectors, replicated to be of length two. Specifies the
(grid) units associated with 
col, col.line, lty, lwd, alpha, border 
Graphical parameters. 
type 
Usually ignored by the panel functions documented here;
the argument is present only to make sure an explicitly specified

fun 
The function that will be applied to the subset of

horizontal 
A logical flag. If 
dmath 
A vectorized function that produces density values given
a numeric vector named 
args 
A list giving additional arguments to be passed to

... 
Further arguments, typically graphical parameters,
passed on to other lowlevel functions as appropriate. Color can
usually be specified by 
identifier 
A character string that is prepended to the names of grobs that are created by this panel function. 
panel.abline
adds a line of the form y = a + b * x
, or
vertical and/or horizontal lines. Graphical parameters are obtained
from the “add.line” settings by default. panel.refline
is similar, but uses the “reference.line” settings for the
defaults.
panel.grid
draws a reference grid.
panel.curve
adds a curve, similar to what curve
does with add = TRUE
. Graphical parameters for the curve are
obtained from the “add.line” setting.
panel.average
treats one of x
and y
as a factor
(according to the value of horizontal
), calculates fun
applied to the subsets of the other variable determined by each unique
value of the factor, and joins them by a line. Can be used in
conjunction with panel.xyplot
, and more commonly with
panel.superpose
to produce interaction plots.
panel.linejoin
is an alias for panel.average
. It is
retained for backcompatibility, and may go away in future.
panel.mathdensity
plots a (usually theoretical) probability
density function. This can be useful in conjunction with
histogram
and densityplot
to visually assess goodness of
fit (note, however, that qqmath
is more suitable for this).
panel.rug
adds a rug representation of the (marginal)
data to the panel, much like rug
.
panel.lmline(x, y)
is equivalent to
panel.abline(lm(y ~ x))
.
Deepayan Sarkar [email protected]
Lattice, panel.axis
, panel.identify
identify
, trellis.par.set
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  ## Interaction Plot
bwplot(yield ~ site, barley, groups = year,
panel = function(x, y, groups, subscripts, ...) {
panel.grid(h = 1, v = 0)
panel.stripplot(x, y, ..., jitter.data = TRUE,
groups = groups, subscripts = subscripts)
panel.superpose(x, y, ..., panel.groups = panel.average,
groups = groups, subscripts = subscripts)
},
auto.key =
list(points = FALSE, lines = TRUE, columns = 2))
## Superposing a fitted normal density on a Histogram
histogram( ~ height  voice.part, data = singer, layout = c(2, 4),
type = "density", border = "transparent", col.line = "grey60",
xlab = "Height (inches)",
ylab = "Density Histogram\n with Normal Fit",
panel = function(x, ...) {
panel.histogram(x, ...)
panel.mathdensity(dmath = dnorm,
args = list(mean=mean(x),sd=sd(x)), ...)
} )

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.