lattice

Trellis graphics is a framework for data visualization developed at Bell Labs by Richard Becker, William Cleveland, et al., extending ideas presented in Bill Cleveland’s 1993 book Visualizing Data.

lattice is best thought of as an implementation of Trellis graphics for R. It is built upon the grid graphics engine and requires the grid add-on package. It is not (readily) compatible with traditional R graphics tools. The public interface is based on the implementation in S-PLUS but features several extensions, in addition to incompatibilities introduced through the use of grid. To the extent possible, care has been taken to ensure that existing Trellis code written for S-PLUS works unchanged (or with minimal change) in lattice. If you are having problems porting S-PLUS code, read the entry for panel in the documentation for xyplot. Most high-level Trellis functions in S-PLUS are implemented, with the exception of piechart.

FunctionDescription
RowsConvenience function to extract a subset of a list. Usually used in creating keys.
as.shingle, as.factorOrShingleFunctions to handle shingles.
axis.defaultDefault function for drawing axes in lattice plots.
bankingCalculates banking slope.
barchartDraws bar charts.
bwplotDraws box plots.
canonical.themeInitialization of a display device with appropriate graphical parameters.
cloudGeneric function to draw 3D scatter plots and surfaces. The "formula" methods do most of the actual work.
col.whitebgInitialization of a display device with appropriate graphical parameters.
contourplotDraws level plots and contour plots.
current.columnReturns an integer index specifying which column in the layout is currently active.
current.panel.limitsUsed to retrieve a panel’s x and y limits.
current.rowReturns an integer index specifying which row in the layout is currently active.
densityplotDraws histograms and kernel density plots, possibly conditioned on other variables.
diag.panel.splomThis is the default superpanel function for splom.
do.breaksDraws histograms and kernel density plots, possibly conditioned on other variables.
dotplotDraws Cleveland dot plots.
draw.colorkeyProduces (and possibly draws) a grid frame grob, which is a color key that can be placed in other grid plots. Used in levelplot.
draw.keyProduces (and possibly draws) a grid frame grob, which is a legend (aka key) that can be placed in other grid plots.
equal.countFunction to handle shingles.
histogramDraws histograms and kernel density plots, possibly conditioned on other variables.
is.shingleFunction to handle shingles.
larrows, llines, lplot.xy, lpoints, lpolygon, lrect, lsegments, ltext, panel.points, panel.polygon, panel.rect, panel.segments, panel.textThese functions are intended to replace common low-level traditional graphics functions, primarily for use in panel functions. The originals cannot be used (at least not easily) because lattice panel functions need to use grid graphics. Low-level drawing functions in grid can be used directly as well and are often more flexible. These functions are provided for convenience and portability.
lattice.getOption, lattice.optionsFunctions to handle settings used by lattice. Their main purpose is to make code maintenance easier, and users normally should not need to use these functions. However, fine control at this level may be useful in certain cases.
latticeParseFormulaUsed by high-level lattice functions like xyplot to parse the formula argument and evaluate various components of the data.
level.colorsCalculates false colors from a numeric variable (including factors, using their numeric codes) given a color scheme and break points.
levelplotDraws level plots and contour plots.
ltransform3dMatrix, ltransform3dto3dThese are (related to) the default panel functions for cloud and wireframe.
make.groupsCombines two or more vectors, possibly of different lengths, producing a data frame with a second column indicating which of these vectors that row came from. This is mostly useful for getting data into a form suitable for use in high-level lattice functions.
onewayFits a one-way model to univariate data grouped by a factor, the result often being displayed using rfs.
packet.numberA function that identifies which packet each observation in the data is part of.
packet.panel.defaultDefault function in lattice to determine, given the column, row, page, and other relevant information, the packet (if any) that should be used in a panel.
panel.3dscatter, panelDefault panel functions controlling cloud and wireframe displays.
panel.ablineAdds a line of the form y = a + bx or vertical and/or horizontal lines.
panel.averageTreats 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.
panel.arrowsDraws arrows in a panel.
panel.axisThe function used by lattice to draw axes. It is typically not used by users, except those wishing to create advanced annotation. Keep in mind issues of clipping when trying to use it as part of the panel function. current.panel.limits can be used to retrieve a panel’s x and y limits.
panel.barchartDefault panel function for barchart.
panel.brush.splompanel.link.splom is meant for use with splom and requires a panel to be chosen using trellis.focus before it is called. Clicking on a point causes that and the corresponding projections in other pairwise scatter plots to be highlighted.
panel.bwplotDefault panel function for bwplot.
panel.cloudDefault panel function controlling cloud and wireframe displays.
panel.contourplotDefault panel function for levelplot.
panel.curveAdds a curve, similar to what curve does with add=TRUE. Graphical parameters for the line are obtained from the add.line setting.
panel.densityplotDefault panel function for densityplot.
panel.dotplotDefault panel function for dotplot.
panel.errorDefault handler used when an error occurs while executing a panel function.
panel.fillFills the panel with a specified color.
panel.gridDraws a reference grid.
panel.histogramDefault panel function for histogram.
panel.identifySimilar to identify. When called, it waits for the user to identify points (in the panel being drawn) via mouse clicks.
panel.levelplotDefault panel function for levelplot.
panel.linejoinpanel.linejoin is an alias for panel.average that was retained for back-compatibility and may go away in the future.
panel.linesPlots lines in a panel.
panel.link.splomThe classic Trellis paradigm is to plot the whole object at once, without the possibility of interacting with it afterward. However, by keeping track of the grid viewports where the panels and strips are drawn, it is possible to go back to them afterward and enhance them one panel at a time. This function provides convenient interfaces to help in this. Note that this is still experimental and the exact details may change in the future.
panel.lmlinepanel.lmline(x, y) is equivalent to panel.abline(lm(y~x)).
panel.loessAdds a smooth curve (fitted by loess).
panel.mathdensityPlots a (usually theoretical) probability density function.
panel.numberReturns an integer counting which panel is being drawn (starting from 1 for the first panel, aka the panel order).
panel.pairsDefault superpanel function for splom.
panel.parallelDefault panel function for parallel.
panel.qqDefault panel function for qq.
panel.qqmathDefault panel function for qqmath.
panel.qqmathlineUseful panel function with qqmath. Draws a line passing through the points (usually) determined by the 0.25 and 0.75 quantiles of the sample and the theoretical distribution.
panel.reflineSimilar to panel.abline, but uses the “reference.line” settings for the defaults.
panel.rugAdds a rug representation of the (marginal) data to the panel.
panel.smoothScatterAllows the user to place smoothScatter plots in lattice graphics.
panel.splomDefault panel function for splom.
panel.stripplotDefault panel function for stripplot. Also see panel.superpose.
panel.superpose, panel.superpose.2These are panel functions for Trellis displays, which are useful when a grouping variable is specified for use within panels. The x (and y where appropriate) variables are plotted with different graphical parameters for each distinct value of the grouping variable.
panel.tmd.default, panel.tmd.qqmathDefault panel functions for tmd.
panel.violinThis is a panel function that can create a violin plot. It is typically used in a high-level call to bwplot.
panel.wireframeDefault panel functions controlling cloud and wireframe displays.
panel.xyplotDefault panel function for xyplot.
parallelDraws conditional scatter plot matrices and parallel coordinate plots.
prepanel.default.bwplot, prepanel.default.cloud, prepanel.default.densityplot, prepanel.default.histogram, prepanel.default.levelplot, prepanel.default.parallel, prepanel.default.qq, prepanel.default.qqmath, prepanel.default.splom, prepanel.default.xyplotThese prepanel functions are used as fallback defaults in various high-level plot functions in lattice. These are rarely useful to normal users, but may be helpful in developing new displays.
prepanel.lmline, prepanel.loess, prepanel.qqmathlineThese are predefined prepanel functions available in lattice.
prepanel.tmd.default, prepanel.tmd.qqmathtmd creates Tukey mean-difference plots from a trellis object returned by xyplot, qq, or qqmath. The prepanel and panel functions are used as appropriate. The formula method for tmd is provided for convenience and simply calls tmd on the object created by calling xyplot on that formula.
qqQuantile-quantile plots for comparing two distributions.
qqmathQuantile-quantile plot of a sample and a theoretical distribution.
rfsPlots fitted values and residuals (via qqmath) on a common scale for any object that has methods for fitted values and residuals.
shingleFunction to handle shingle.
show.settingsFunction used to query, display, and modify graphical parameters for fine control of Trellis displays. Modifications are made to the settings for the currently active device only.
simpleKeySimple interface to generate a list appropriate for draw.key.
simpleThemeSimple interface to generate a list appropriate as a theme, typically used as the par.settings argument in a high-level call.
splomDraws conditional scatter plot matrices and parallel coordinate plots.
standard.themeInitialization of a display device with appropriate graphical parameters.
strip.customProvides a convenient way to obtain new strip functions that differ from strip.default only in the default values of certain arguments.
strip.defaultFunction that draws the strips by default in Trellis plots. Users can write their own strip functions, but most commonly this involves calling strip.default with slightly different arguments.
stripplotDraws strip plots in lattice.
tmdtmd creates Tukey mean-difference plots from a trellis object returned by xyplot, qq, or qqmath. The formula method for tmd is provided for convenience and simply calls tmd on the object created by calling xyplot on that formula.
trellis.currentLayoutReturns a matrix with as many rows and columns as in the layout of panels in the current plot.
trellis.deviceInitialization of a display device with appropriate graphical parameters.
trellis.focus, trellis.grobnametrellis.focus can be used to move to a particular panel or strip, identified by its position in the array of panels.
trellis.last.objectUpdates method for objects of class "trellis" and is a way to retrieve the last printed trellis object (that was saved).
trellis.panelArgsOnce a panel or strip is in focus (e.g., by using trellis.switchFocus), trellis.panelArgs can be used to retrieve the arguments that were available to the panel function at that position.
trellis.par.get, trellis.par.setFunctions used to query, display, and modify graphical parameters for fine control of Trellis displays. Modifications are made to the settings for the currently active device only.
trellis.switchFocusA convenience function to switch from one viewport to another, while preserving the current row and column.
trellis.unfocusUnsets the focus and makes the top-level viewport the current viewport.
trellis.vpnameReturns the name of a viewport.
which.packetReturns the combination of levels of the conditioning variables in the form of a numeric vector as long as the number of conditioning variables, with each element an integer indexing the levels of the corresponding variable.
wireframeGeneric function to draw 3D scatter plots and surfaces. The "formula" methods do most of the actual work.
xscale.components.default, yscale.components.defaultReturn a list of the form suitable as the components argument of axis.default.
xyplotProduces conditional scatter plots.
Data SetClassDescription
barleydata.frameTotal yield in bushels per acre for 10 varieties at 6 sites in each of 2 years.
environmentaldata.frameDaily measurements of ozone concentration, wind speed, temperature, and solar radiation in New York City from May to September of 1973.
ethanoldata.frameEthanol fuel was burned in a single-cylinder engine. For various settings of the engine compression and equivalence ratio, the emissions of nitrogen oxides were recorded.
melanomadata.frameThis data from the Connecticut Tumor Registry presents age-adjusted numbers of melanoma skin cancer incidences per 100,000 people in Connecticut for the years 1936–1972.
singerdata.frameHeights, in inches, of the singers in the New York Choral Society in 1979. The data is grouped according to voice part. The vocal range for each voice part increases in pitch according to the following order: Bass 2, Bass 1, Tenor 2, Tenor 1, Alto 2, Alto 1, Soprano 2, Soprano 1.