Does this do what you want? The "panel" argument has the custom pane function I referred to before.
Col <- c("red", "green", "blue", "purple") xyplot ( SnowLineElevation ~ Year | Model, data = d, panel = function(x, y, col, ...) { Col <- Col[panel.number()] panel.xyplot(x, y, col = "blue", ...) panel.loess(x, y, col = Col) }, ylim = c(0,100), type = c('p','smooth'), col = 'blue', pch = 21, xlab = 'Year', ylab = 'Snowline Elevation [m]' ) On Mon, Feb 2, 2009 at 12:18 PM, Hutchinson,David [PYR] <david.hutchin...@ec.gc.ca> wrote: > I haven't had much luck with a custom panel function; mainly because I > don't truly understand how to embedd the functionality into the xyplot > command. > > Here's a reproducible example if you can help out. > > Thanks, > Dave > > library (lattice) > > d <- NULL > models <- c('A','B','C','D') > n = 100 > for (i in seq(along = models)){ > d <- rbind( > d, data.frame ( > Model = models[i], > Year = seq(1960, length.out=n, by = 1), > SnowLineElevation = runif(n, 0, 100) > ) > ) > } > > xyplot ( > SnowLineElevation ~ Year | Model, > data = d, > ylim = c(0,100), > type = c('p','smooth'), > col = 'blue', > pch = 21, > xlab = 'Year', > ylab = 'Snowline Elevation [m]' > ) > > -----Original Message----- > From: Sundar Dorai-Raj [mailto:sdorai...@gmail.com] > Sent: Monday, February 02, 2009 11:43 AM > To: Hutchinson,David [PYR] > Cc: r-help@r-project.org > Subject: Re: [R] xyplot with lowess curves > > You'll need a custom panel function. It would also help if you provided > a reproducible example: > > xyplot ( > SnowLineElevation ~ Year | Model, > data = data, > panel = function(x, y, col, ...) { > col <- ifelse(panel.number() == 1, "red", "green") > panel.xyplot(x, y, col = "blue", ...) > panel.loess(x, y, col = col) > }, > ylim = c(0,1800), > pch = 21, > xlab = 'Year', > ylab = 'Snowline Elevation [m]' > ) > > Alternatively, you can use the group argument in conjunction with the > panels: > > xyplot(SnowLineElevation ~ Year | Model, data, groups = Model, type = > c("p", "smooth")) > > if you want the points and the lines to be the same color. > > --sundar > > On Mon, Feb 2, 2009 at 10:20 AM, Hutchinson,David [PYR] > <david.hutchin...@ec.gc.ca> wrote: >> I am trying to change the attributes of the lowess lines fit to an >> xyplot command, but have been unsuccessful in my search of the online >> help. Right now, both the points and lowess line come out in the same >> color (blue). I am unsure how I can change the properties of the >> lowess line separately. >> >> xyplot ( >> SnowLineElevation ~ Year | Model, >> data = data, >> ylim = c(0,1800), >> type = c('p','smooth'), >> col = 'blue', >> pch = 21, >> xlab = 'Year', >> ylab = 'Snowline Elevation [m]' >> ) >> >> Any help would be much appreciated, >> >> Dave >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.