To learn more about panel functions see the help page for xyplot and especially the panel argument. You can get what you want by
contourplot(z~x*y,data=grid,region=T, col.regions=gray(seq(1,0,len=255)), colorkey=T,cuts=50,contour=F, panel = function(x,y,z,...){ panel.contourplot(x,y,z,...) llines(x=c(-5,5),y=c(-5,5),lwd=5,col="blue") }) or contourplot(z~x*y,data=grid,region=T, col.regions=gray(seq(1,0,len=255)), colorkey=T,cuts=50,contour=F, panel = function(x,y,z,...){ panel.contourplot(x,y,z,...) panel.abline(0,1,lwd=5,col="blue") }) Med venlig hilsen / Regards Frede Aakmann Tøgersen Forsker / Scientist AARHUS UNIVERSITET / UNIVERSITY OF AARHUS Det Jordbrugsvidenskabelige Fakultet / Faculty of Agricultural Sciences Inst. for Genetik og Bioteknologi / Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Tel: +45 8999 1900 Direct: +45 8999 1878 Mobile: +45 E-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> Web: www.agrsci.dk <https://djfpost.agrsci.dk/exchweb/bin/redir.asp?URL=http://www.agrsci.dk/> ________________________________ Tilmeld dig DJF's nyhedsbrev / Subscribe Faculty of Agricultural Sciences Newsletter <https://djfpost.agrsci.dk/exchweb/bin/redir.asp?URL=http://www.agrsci.dk/user/register?lan=dan-DK> . Denne email kan indeholde fortrolig information. Enhver brug eller offentliggørelse af denne email uden skriftlig tilladelse fra DJF er ikke tilladt. Hvis De ikke er den tiltænkte adressat, bedes De venligst straks underrette DJF samt slette emailen. This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. ________________________________ Fra: [EMAIL PROTECTED] på vegne af Richard D. Morey Sendt: fr 07-09-2007 03:28 Til: r-help@stat.math.ethz.ch Emne: [R] contourplot lines, text, and mtext If I have a contourplot (in the lattice package) and I want to add straight lines to it, how do I do this? I see that there are llines() and lsegement() functions for lattice plots, but they don't seem to do anything in this case: library(lattice) library(KernSmooth) x=rnorm(10000) y=x+rnorm(x,0,.5) a=bkde2D(cbind(x,y),.7) z=as.vector(a$fhat) grid=expand.grid(x=a$x1,y=a$x2) grid$z=z contourplot(z~x*y,data=grid,region=T,col.regions=gray(seq(1,0,len=255)),colorkey=T,cuts=50,contour=F) llines(x=c(-5,5),y=c(-5,5)) > NULL lsegments(x0=-5,y0=-5,x1=5,y1=5) I'm just trying to do the equivalent of abline(0,1) on the plot. ltext(), on the other hand, seems to like to place text in the upper left corner of the plot. I suspect that I misunderstand the coordinate system that lattice uses for contour plots. Can anyone enlighten me? Richard -- Richard D. Morey, M.A. Research Assistant, Perception and Cognition Lab University of M issouri-Columbia ______________________________________________ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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.