\Header{panel.functions}{Useful Panel Functions}
\alias{panel.abline}{panel.functions}
\alias{panel.axis}{panel.functions}
\alias{panel.curve}{panel.functions}
\alias{panel.fill}{panel.functions}
\alias{panel.grid}{panel.functions}
\alias{panel.linejoin}{panel.functions}
\alias{panel.lmline}{panel.functions}
\alias{panel.loess}{panel.functions}
\alias{panel.mathdensity}{panel.functions}
\alias{panel.rug}{panel.functions}
\keyword{dplot}{panel.functions}
\begin{Description}\relax
These are predefined panel functions available in lattice for use in
constructing new panel functions (usually on-the-fly).
\end{Description}
\begin{Usage}
\begin{verbatim}
panel.abline(a, b, ...)
panel.abline(coef, ...)
panel.abline(reg, ...)
panel.abline(h= ,v= , ...)
panel.curve(expr, from, to, n = 101,
            curve.type = "l", ...)
panel.rug(x = NULL, y = NULL,
          regular = TRUE, start, end, ...)
panel.fill(col="grey", ...)
panel.grid(h=3, v=3, ...)
panel.lmline(x,y,...) = panel.abline(lm(y~x),...)
panel.loess(x, y, span = 2/3, degree = 1,
            family = c("symmetric", "gaussian"),
            evaluation = 50, ...)
panel.linejoin(x, y, fun = mean, horizontal = TRUE, ...)
panel.mathdensity(dmath = dnorm, args = list(mean=0, sd=1))
panel.axis(side = 1:4, at,
           labels = TRUE, tick = TRUE,
           half = TRUE, which.half = c("lower", "upper", "upper","lower"),
           tck = 1, rot)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x, y}] variables defining the contents of the panel
\item[\code{a, b}] Coefficients of the line to be added
\item[\code{coef}] Coefficients of the line to be added as a length 2 vector
\item[\code{reg}] A regression object. The corresponding fitted line will
be drawn 
\item[\code{h,v}] For panel.abline, numerical vectors giving y and x
locations respectively of horizontal and vertical lines to be
added to the plot. For panel.grid, number of horizontal and vertical
reference lines to be added to the plot; h=-1 and v=-1 make the
grids aligned with the axis labels (this doesn't always work).

\item[\code{expr}] expression as a function of x or a function to plot as a
curve

\item[\code{regular}] logical indicating whether `rug' to be drawn on the
regular side (left / bottom) or not (right / top)

\item[\code{start, end}] endpoints of rug segments, in normalized parent
coordinates (between 0 and 1). Defaults depend on value of regular,
and cover 3\% of the panel width and height

\item[\code{from, to}] optional lower and upper x-limits of curve. If
missing, limits of current panel are used

\item[\code{n}] number of points to use for drawing the curve 
\item[\code{curve.type}] type of curve ('p' for points, etc), passed to
\code{llines}

\item[\code{col}] color
\item[\code{span, degree, family, evaluation}] arguments to 
\code{loess.smooth} in the \code{modreg} library. \code{panel.loess}
is essentially a wrapper on \code{loess.smooth} 

\item[\code{fun}] the function that will be applied to the subset of x(y)
determined by the unique values of y(x)
\item[\code{horizontal}] logical. If FALSE, the plot is `transposed' in the
sense that the behaviours of x and y are switched. x is now
the `factor'.  Interpretation of other arguments change
accordingly. See documentation of \code{bwplot} for a fuller
explanation.

\item[\code{dmath}] A vectorized function that produces density values
given a numeric vector named \code{x}, e.g., \code{dnorm}
\item[\code{args}] list giving additional arguments to be passed to dmath
\item[\code{side}] subset of 1:4, indicating which side which 
\item[\code{at}] location of labels. No default.
\item[\code{labels}] logical indicating whether labels are to be drawn, or
the labels to go along with \code{at}
\item[\code{tick}] logical, whether to draw ticks 
\item[\code{half}] logical, whether only half of scales will be drawn for each side

\item[\code{which.half}] character vector of length 4 (recycled if necessary), each being
either ``lower'' or ``upper''. Indicates which half is to be used
for tick locations if \code{half = TRUE}, for sides 1 to 4

\item[\code{tck}] numeric scalar, tick length 
\item[\code{rot}] numeric 4-vector (recycled if necessary), rotation angles for sides
1 to 4

\item[\code{...}] graphical parameters can be supplied. see function
definition for details. Color can usually be specified by \code{col,
      col.line} and \code{col.symbol}, the last two overriding the first
for lines and points respectively.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{panel.abline} adds a line of the form \code{y=a+bx} or vertical
and/or horizontal lines. Graphical parameters are obtained from 
\code{reference.line} for panel.grid, and \code{add.line} for the
others (can be set using \code{trellis.par.set} )

\code{panel.curve} adds a curve, similar to what \code{curve} does
with \code{add = TRUE}. Graphical parameters for the line are obtained
from the \code{add.line} setting.

\code{panel.linejoin} treats one of x and y as a factor (according to
the value of \code{horizontal}, calculates \code{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
\code{panel.xyplot} and more commonly with panel.superpose to produce
interaction plots. See \code{\Link{xyplot}} documentation for an example.

\code{panel.mathdensity} plots a (usually theoretical) probability
density function. Can be useful in conjunction with \code{histogram}
and \code{densityplot} to visually estimate goodness of fit.

\code{panel.axis} draws axis tick marks INSIDE a panel. It honours the
(native) axis scales within the panel, but the locations need to be
explicitly specified. Used in \code{\Link{panel.pairs}} for
\code{\Link{splom}}.
\end{Details}
\begin{Author}\relax
Deepayan Sarkar \email{deepayan@stat.wisc.edu}
\end{Author}
\begin{SeeAlso}\relax
\code{\Link{loess.smooth}},
\code{\Link{trellis.par.get}}
\end{SeeAlso}

