On 12/11/2009 02:03 PM, PtitBleu wrote: > Hello, > > I would like to get a lattice plot of 8 panels (unique(df$fact)=8) with 2 > graphs (df$y1 and df$y2 as a function of df$x) and 1 red point at (500, > ymax) per panel. > > The script below is quite ok but I'm not able to define two different colors > for the two graphs. > If you have an idea how to use the "col" function in order to attribute the > colors, it will be very kind of you to share it with a newbie. > > Have a nice week-end, > Ptit Bleu. > > > x11(15,12) > xyplot(df$y1 + df$y1/df$coeff ~ df$x | df$fact, > panel = function(x, y) { > panel.grid(h=-1, v=-1, col="gray") > panel.xyplot(x, y, type="p", pch=20) > panel.points(500, ymax[panel.number()], col="red", pch=20, > cex=1.6) > }, > xlab="X", ylab="Y") > > If you add '...' to your panel function, it will allow the panel function to use the info you did not provide explicitly:
panel = function(x, y, ...) { panel.grid(h=-1, v=-1, col="gray") panel.xyplot(x, y, type="p", pch=20, ...) panel.points(500, ymax[panel.number()], col="red", pch=20, cex=1.6) }, I tested with: library(lattice) tmp <- data.frame(y1=11:20,coeff=1:10,x1=21:30) xyplot(y1 + y1/coeff ~ x1, data=tmp, panel=function(x,y,...) { panel.xyplot(x, y, type="p", pch=20, ...) } ) Stephan ______________________________________________ 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.