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")
panel.grid
these are optional and are used only to choose
an appropriate method of pretty
.
panel.abline
. a
can be a vector of length 2,
representing the coefficients of the line to be added, in which case
b
should be missing. a
can also be an appropriate
regression object, i.e., an object which has a
coef
method that returns a length 2 numeric vector.
The corresponding line will be plotted. The reg
argument
overrides a
if specified.
coef
method that gives the coefficints of the corresponding regression
line. panel.abline
, these are numeric vectors giving
locations respectively of horizontal and vertical lines to be added
to the plot, in native coordinates. For panel.grid
, these usually specify the number of
horizontal and vertical reference lines to be added to the plot.
Alternatively, they can be negative numbers. h=-1
and
v=-1
are intended to make the grids aligned with the axis
labels. This doesn't always work; all that actually happens is that
the locations are chosen using pretty
, which is also how the
label positions are chosen in the most common cases (but not for
factor variables, for instance). h
and v
can be
negative numbers other than -1
, in which case -h
and
-v
(as appropriate) is supplied as the n
argument to
pretty
.
If x
and/or y
are specified in panel.grid
, they
will be used to select an appropriate method for
pretty
. This is particularly useful while plotting
date-time objects.
panel.abline
should be taken from
the reference.line parameter settings. The default is to
take them from the add.line settings. The
panel.refline
function is a wrapper around
panel.abline
that calls it with reference = TRUE
.
x
, or a
function, to be plotted as a curve. "p"
for points, etc), passed
to llines
regular
, and cover 3% of the panel width and height. start
and end
above.
x.units
and y.units
are for the rug on the x-axis and
y-axis respectively (and thus are associated with start
and
end
values on the y and x scales respectively).
type
argument (perhaps meant for another function) does not
affect the display.
x
values (or y
if horizontal
is FALSE
)
determined by the unique values of y
(x
). FALSE
, the plot is
transposed in the sense that the roles of x
and
y
are switched; x
is now the factor.
Interpretation of other arguments change accordingly. See
documentation of bwplot
for a fuller explanation.
x
, e.g., dnorm
.
dmath
.
col
, col.line
, and
col.symbol
, the last two overriding the first for lines and
points respectively.
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 back-compatibility, 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))
.
panel.axis
, panel.identify
identify
, trellis.par.set
.
## 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)), ...)
} )
Run the code above in your browser using DataLab