Dear R-users,

I have a plot created with the code below. I tried to put some text to the 
right of the color key. I worked with grid.text and also viewport(), but 
couldn't achieve this. I know this should be simple, but I just couldn't figure 
out how to do it. How does this work?

Cheers,

Marius

library(lattice) 
library(grid)
myvec=1:10
data=data.frame(x=myvec,y=myvec)
mygray=function(l) gray(seq(0.2,0.8,length=l))
colors=level.colors(data[1:10,2],at=do.breaks(c(1,10),10),col.regions=mygray)
colorvec=colors[1:10]
#trellis.device(postscript,color=F,horizontal=F,onefile=F)
xyplot(data[,2]~data[,1],aspect=1,
        panel=function(...){
                panel.xyplot(...,type="n")
                lpoints(data[,1],data[,2],pch=1,col=colorvec)
                grid.text("text to the right of the color 
key",1.2,0.5,rot=90)#does not work.
        },
        xlab="x",ylab="y",
        
legend=list(right=list(fun=draw.colorkey,args=list(key=list(col=mygray(10),at=1:10))))
)
#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.

Reply via email to