Hi
> -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of iwaite > Sent: Tuesday, August 28, 2012 12:49 AM > To: r-help@r-project.org > Subject: Re: [R] Lattice graphics adding abline line (1:1 line) ??? > > I have read multiple books and looked at many posts online and can't > seem to figure out how to add a 1:1 line in lattice xyplot. I've tried > multiple versions of getting this to work, including trying > "panel.abline(h=0,v=1), panel=function and others. here is small function which will add arbitrary line(s) to lattice panels function (a = NULL, b = NULL, v = NULL, h = NULL, ..., once = F) { tcL <- trellis.currentLayout() k <- 0 for (i in 1:nrow(tcL)) for (j in 1:ncol(tcL)) if (tcL[i, j] > 0) { k <- k + 1 trellis.focus("panel", j, i, highlight = FALSE) if (once) panel.abline(a = a[k], b = b[k], v = v[k], h = h[k], ...) else panel.abline(a = a, b = b, v = v, h = h, ...) trellis.unfocus() } } parameter once is used if you want different values in each panel. Regards Petr > > Second question, how do I get the legend created via "auto.key" to use > the > "pch=c(15,16,17,18) and associated colors, these are circle, > square,triangle and diamond, but the auto.key just plots points with > different default colors, not the grey scales and symbols that the > actual plots uses, how do I get these to match. Is auto.key not the way > to go, again I read on many different methods, but no luck yet. > > Thanks, > Ian > > xyplot(Inv591$RichTOL~gbm_tol$fitted, data=Inv591,group=EcoRegion, > main= "Observed vs Predicted for RichTOL (BRT development > model)",xlab="Observed RichTOL", ylab="Predicted RichTOL", xlim= > c(2,8), ylim= c(2,8), pch=c(15,16,17,18), cex=1.1, > col=c('grey10','grey30','grey60','grey80'),cex.lab=1.8, > cex.axis=1.8,font=2, auto.key=list(corner=c(1,0)), panel=function(x,y){ > panel.xyplot(x,y) > panel.abline(lm(Inv591$RichTOL~gbm_tol$fitted)) > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Lattice- > graphics-with-combined-plot-types-tp790070p4641486.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.