The lattice library is the R version of W. Cleveland's "Trellis" library in S. Its goal is produce powerful multipanel plots optimized for (static) viewing and printing.

Lattice is a very powerfull addition to the graphical possibilities of R; the numerous functions of the libary use a standard way of specifying arguments, i.e. you are usins formulae to specify the variables you want to plot.

The overall philosophy of lattice is somewhat different from the basic R graphic functions: you specify everything in a single, often quite lengthy function call, whereas in R you usually produce a particular graph and then enhance it with additional function calls to add a title, a smooth curve and so on.

Although Trellis (S-plus) and Lattice (R) are mostly identical, they are different implementations of the same principles. Trellis is based on the standard R graphics engine (base), lattice is based on the grid engine. This has one consequence, you can use standard functions, e.g. for adding a legend, to modify Trellis graphs, whereas in lattice these do not work, you need to use the lattice supplied functions, e.g. instead of using title() (base graph) you will have to use ltitle().

Activate the library using


Most documents on this site explaining a particular graph type (e.g. boxplots, scatterplots) have a section on the corresponding lattice functions.

See also·