[R] help change auto.key colors in xyplot

Dimitri Liakhovitski ld7631 at gmail.com
Fri Feb 13 13:56:09 CET 2009


Dear lettice gurus,
the code below works just fine to produce a dotplot. However, I am not
successful changing the color of the lines in the legend (auto.key).
If I add col=..., it only changes the color of the letters in the
legend, but not the color of the lines.
Really appreciate any advice on that!
Dimitri

library(lattice)
d=data.frame(xx=c(2.2,2.1,3.3),yy=c(0.1,0.2,0.3),zz=c(2.5,2.0,1.8))
d[[2]]<-as.factor(d[[2]])
dotplot(c(d[[1]],d[[3]])~rep(d[[2]],2),groups=rep(c("Group 1","Group
2"),each=nrow(d)),main=list("Chart Title",cex=1),
    xlab=list("Title for X",cex=.9,font=2),
    ylab=list("Title for Y",cex=.9,font=2),
    auto.key = list(space = "top", points = T, lines = T,cex=.9),
    panel = function(y,x,...){
			panel.grid(h = -1, v = -1, col = "gray", lty ="dotted", ltx="dotted")
      panel.superpose(x,y,..., type="b",col.line=c("blue","red"),pch=20,cex=1.3,
      col=c("blue","red"),bg=c("blue","red"),lwd=2)
      ltext(x, y, labels=round(y,3),
cex=.8,col="black",font=2,adj=c(-0.2,1)) # adds labels to those
circles # pos=2,
      panel.abline(h=0)
	}
)

-- 
Dimitri Liakhovitski
MarketTools, Inc.
Dimitri.Liakhovitski at markettools.com




More information about the R-help mailing list