[Forgot to CC r-help]

---------- Forwarded message ----------
From: Deepayan Sarkar <deepayan.sar...@gmail.com>
To: Gerrit Draisma <g.drai...@erasmusmc.nl>


On 6/6/09, Gerrit Draisma <g.drai...@erasmusmc.nl> wrote:
 > Hallo R-users,
 >  I do not understand how to specify the correct
 >  line and symbol types in the legends of a lattice xyplot.
 >  This is what I tried, but the line types and symbol  in the
 >  graph are not seen in the legend.
 >  Any help is appreciated.
 >
 >  Thanks,
 >  Gerrit.
 >
 >  library(lattice)
 >  s<-rep(1:3,len=10)
 >  x<- 1:10
 >  y<- x+s+rnorm(10)
 >  d<-data.frame(s,x,y)
 >  xyplot(y~x, groups=s,data=d, type="b",


Instead of


   pch=1:3,lty=1:3,


try

   par.settings = simpleTheme(pch=1:3,lty=1:3),


 > auto.key=list(text=c("A","B","C"),points=FALSE,lines=TRUE,
 >   type="b",lty=1:3,divide=1,pch=1:3,columns=3))


The lty and pch in auto.key are not used.

 Alternatively, you could use the classic approach using key, where you
 need specify all parameters again in the key. You are already pretty
 close to that:


 xyplot(y~x, groups=s,data=d, type="b", pch=1:3,lty=1:3,

       key=list(text=list(c("A","B","C")),
                lines=list(lty=1:3, pch=1:3, type="b"),
                divide=1, columns=3))

 You'll need to add matching colors as well.


 -Deepayan

______________________________________________
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