Lattice superposition: (was [R] trellis plot)

Prof Brian Ripley ripley at
Wed Nov 28 23:20:41 CET 2001

On Wed, 28 Nov 2001, Brad Buchsbaum wrote:

> Hi,
> I'd like to plot 4 groups of data using xyplot and panel.superpose so
> that the points are overlayed on a single plot.  For each group of data
> I'd also like a loess smoothed function (using panel.loess).  I have
> tried the following:
> xyplot(series ~ time | gr, data=etable,
>          panel = function(x,y, ...) {
>            panel.superpose(x,y, ...)
>            panel.loess(x,y,span=.15)
>            }
> )
> However, this gives me only a single loess curve (collapsed across
> groups) whereas I would like one curve for each group (just as I get one
> color for each set of points from the panel.superpose).
> Is there a way to accomplish this?

Make a copy of panel.superpose, say panel.multiloess, and replace the
call inside it to panel.xyplot by a call to panel.loess.

Or start with panel.loess and add subscripts and groups arguments a la

Generally, when using Trellis (and Lattice) you need to customize panel
(and prepanel) functions.

Brian D. Ripley,                  ripley at
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

r-help mailing list -- Read
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at

More information about the R-help mailing list