An Overview of the Lattice Package
Lattice graphics consist of one or more rectangular drawing areas called panels. The data assigned to each panel is referred to as a packet. Lattice functions work by calling one or more panel functions, which actually plot the packets within panels. To change the appearance of a plot, you can specify arguments to the plotting function or change the panel function.
How Lattice Works
Here is what typically happens in a lattice session:
The end user calls a high-level lattice plotting function.
The
lattice
function examines the calling arguments and default parameters, assembles a lattice object, and returns the object. (Note that the class of the object is actually “trellis.” This means that many of the methods that act on an object, likeprint
orplot
, are namedplot.trellis
orprint.trellis
.)The user calls
print.lattice
orplot.lattice
with the lattice object as an argument. (This typically happens automatically on the R console.)The function
plot.lattice
sets up the matrix of panels, assigns packets to different panels (specified by the argumentpacket.panel
) and then calls the panel function specified in the lattice object to draw the individual panels.
Lattice graphics are extremely modular; they share many high-level
functions (like plot.lattice
) and
low-level functions (like panel.axis
, which draws axes). This means that they share many common arguments. It also means that you can customize the appearance of lattice graphics by creating substitute ...
Get R in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.