Learn R Programming

lattice (version 0.20-45)

A_01_Lattice: Lattice Graphics

Description

The lattice add-on package is an implementation of Trellis graphics for R. It is a powerful and elegant high-level data visualization system with an emphasis on multivariate data. It is designed to meet most typical graphics needs with minimal tuning, but can also be easily extended to handle most nonstandard requirements.

Arguments

Author

Deepayan Sarkar Deepayan.Sarkar@R-project.org

Details

Trellis Graphics, originally developed for S and S-PLUS at the Bell Labs, is a framework for data visualization developed by R. A. Becker, W. S. Cleveland, et al, extending ideas presented in Cleveland's 1993 book Visualizing Data. The Lattice API is based on the original design in S, but extends it in many ways.

The Lattice user interface primarily consists of several ‘high-level’ generic functions (listed below in the “See Also” section), each designed to create a particular type of display by default. Although the functions produce different output, they share many common features, reflected in several common arguments that affect the resulting displays in similar ways. These arguments are extensively (sometimes only) documented in the help page for xyplot, which also includes a discussion of the important topics of conditioning and control of the Trellis layout. Features specific to other high-level functions are documented in their respective help pages.

Lattice employs an extensive system of user-controllable settings to determine the look and feel of the displays it produces. To learn how to use and customize the graphical parameters used by lattice, see trellis.par.set. For other settings, see lattice.options. The default graphical settings are (potentially) different for different graphical devices. To learn how to initialize new devices with the desired settings or change the settings of the current device, see trellis.device.

It is usually unnecessary, but sometimes important to be able to plot multiple lattice plots on a single page. Such capabilities are described in the print.trellis help page. See update.trellis to learn about manipulating a "trellis" object. Tools to augment lattice plots after they are drawn (including locator-like functionality) are described in the trellis.focus help page.

The online documentation accompanying the package is complete, and effort has been made to present the help pages in a logical sequence, so that one can learn how to use lattice by reading the PDF reference manual available at https://cran.r-project.org/package=lattice. However, the format in which the online documentation is written and the breadth of topics covered necessarily makes it somewhat terse and less than ideal as a first introduction. For a more gentle introduction, a book on lattice is available as part of Springer's ‘Use R’ series; see the “References” section below.

References

Sarkar, Deepayan (2008) Lattice: Multivariate Data Visualization with R, Springer. ISBN: 978-0-387-75968-5 http://lmdvr.r-forge.r-project.org/

Cleveland, William .S. (1993) Visualizing Data, Hobart Press, Summit, New Jersey.

Becker, R. A. and Cleveland, W. S. and Shyu, M. J. (1996). “The Visual Design and Control of Trellis Display”, Journal of Computational and Graphical Statistics, 5(2), 123--155.

Bell Lab's Trellis Page contains several documents outlining the use of Trellis graphics; these provide a holistic introduction to the Trellis paradigm: http://web.archive.org/web/20081020164041/http://cm.bell-labs.com/cm/ms/departments/sia/project/trellis/display.writing.html

See Also

The following is a list of high-level functions in the lattice package and their default displays. In all cases, the actual display is produced by the so-called “panel” function, which has a suitable default, but can be substituted by an user defined function to create customized displays. In many cases, the default panel function will itself have many optional arguments to customize its output. The default panel functions are named as “panel.” followed by the name of the corresponding high-level function; i.e., the default panel function for xyplot is panel.xyplot, the one for histogram is panel.histogram, etc. Each default panel function has a separate help page, linked from the help pages of the corresponding high-level function. Although documented separately, arguments to these panel functions can be supplied directly to the high-level functions, which will pass on the arguments appropriately.

Univariate:

barchart:

Bar plots.

bwplot:

Box-and-whisker plots.

densityplot:

Kernel density estimates.

dotplot:

Cleveland dot plots.

histogram:

Histograms.

qqmath:

Theretical quantile plots.

stripplot:

One-dimensional scatterplots.

Bivariate:

qq:

Quantile plots for comparing two distributions.

xyplot:

Scatterplots and time-series plots (and potentially a lot more).

Trivariate:

levelplot:

Level plots (similar to image plots).

contourplot:

Contour plots.

cloud:

Three-dimensional scatter plots.

wireframe:

Three-dimensional surface plots (similar to persp plots).

Hypervariate:

splom:

Scatterplot matrices.

parallel:

Parallel coordinate plots.

Miscellaneous:

rfs:

Residual and fitted value plots (also see oneway).

tmd:

Tukey Mean-Difference plots.

In addition, there are several panel functions that do little by themselves, but can be useful components of custom panel functions. These are documented in panel.functions. Lattice also provides a collection of convenience functions that correspond to the traditional graphics primitives lines, points, etc. These are implemented using Grid graphics, but try to be as close to the traditional versions as possible in terms of their argument list. These functions have names like llines or panel.lines and are often useful when writing (or porting from S-PLUS code) nontrivial panel functions.

Finally, many useful enhancements that extend the Lattice system are available in the latticeExtra package.

Examples

Run this code
if (FALSE) {

## Show brief history of changes to lattice, including
## a summary of new features.

RShowDoc("NEWS", package = "lattice")
}

Run the code above in your browser using DataLab