O'Reilly logo

The R Book by Michael J. Crawley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Trellis Plots

You need to load the lattice package and set the background colour to white. You can read the details in ?trellis.device.

library(lattice)

The most commonly use trellis plot is xyplot, which produces conditional scatterplots where the response, y, is plotted against a continuous explanatory variable x, for different levels of a conditioning factor, or different values of the shingles of a conditioning variable. This is the standard plotting method that is used for linear mixed-effects models and in cases where there are nested random effects (i.e. with groupedData see p. 668). The structure of the plot is typically controlled by the formula; for example

xyplot(y~x | subject)

where a separate graph of y against x is produced for each level of subject (the vertical bar | is read as ‘given’). If there are no conditioning variables, xyplot(y~x), the plot produced consists of a single panel. All arguments that are passed to a high-level trellis function like xyplot that are not recognized by it are passed through to the panel function. It is thus generally good practice when defining panel functions to allow a ... argument. Such extra arguments typically control graphical parameters.

Panels are by default drawn starting from the bottom left-hand corner, going right and then up, unless as.table = TRUE, in which case panels are drawn from the top left-hand corner, going right and then down. Both of these orders can be modified using the index.cond and perm.cond arguments. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required