Happy New Year to all R users! I have two short questions concerning a xyplot with a color key:
1) How do I properly place (align) the color key beside the xyplot? As you can see from the code listed below, the placement of the color key is not correct. I would like the upper and lower end point of the color key to be perfectly aligned with the upper and lower line of the xyplot. Adjusting the viewport-arguments below is tedious and also does not help if you want the print the plot in a postscript file (see the commented lines below). 2) How do I put a label on the color key? I would like to give the color key a label as the label 'x' for the y- axis, so it should be vertically printed and located to the right of the color key. I tried to give the 'key' argument in 'draw.colorkey' some arguments, but I could not manage to put a label on the color key. Thanks very much. Marius library(lattice) library(grid) x=c(1,2,3) colorseq=c(0.2,0.5,0.8) mycolors=gray(colorseq) #trellis.device(postscript,horizontal=F,onefile=F,file="~/testplot.ps") xyplot(x~x,col=mycolors,aspect=1) draw.colorkey(key=list(at=seq(1,3,length=4),col=mycolors,text=list(c ("test"))),draw=TRUE,vp=viewport(x=1,y=0.6,height=0.8)) #dev.off() ______________________________________________ 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.