Hello, I have two short questions concerning a key (legend) in a lattice plot. I have points represented by two different plot characters (crosses and circles) and they are colored from light to dark gray. I would like to have 3 parts in my legend showing the two different plot characters in the first two lines and the last line should consist of a line segment for explaining the different shades of gray. Below you can see what I reached so far. My first problem is, that I do not get the 2 plot characters and the line segment vertically aligned to each other (I chose the vector of plotting characters to contain "26" as last element, because this leaves out a plotting character for the last line, where the line segment should be placed). So how do I get these aligned? My second question is, if it's possible to have a line segment shown in the key, which is colored from light to dark gray (instead of a single color), matching the colors in my specified variable "colors" if possible, i.e. a single line segment starting from light gray and ending with a dark gray.
Thanks very much in advance! Jan library(lattice) x=c(1,2,3,4,5) y=c(5,4,3,2,1) symbolvec=c(3,3,3,1,3) colorseq=seq(0.25,0.88,length=5) colors=gray(colorseq) colorvec=colors xyplot(y~x, panel=function(...){ panel.xyplot(...,type="n") lpoints(x,y,pch=symbolvec,col=colorvec) }, key=list(x=0.2,y=0.2,lines=list(lty=c(0,0,1)),points=list(pch=c (1,3,26)),text=list(c("key 1","key 2","key 3")),align=T,transparent=T)) ______________________________________________ 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.