[R] lattice: passing multiple lty values to the key/legend

Peter Ehlers ehlers at ucalgary.ca
Fri Oct 9 01:29:22 CEST 2009


Try setting lty with par.settings:

  xyplot(v3~v2,data=xx,
    xlab='',
#   group=v1,type='l', lty=1:3  ,
    groups=v1, type='l',
    par.settings = list(superpose.line = list(lty = 1:3)),
    auto.key = list(text=levels(as.factor(xx$v1)) , title='',
      cex.title=.75,points=F,lines = T,cex=1,
      x = .5, y = -0.1,corner = c(0, 0),
      between=1,columns=3,between.columns=2),
  )

and since 'v1' should be a factor in xx, you don't need the
as.factor() in auto.key.

  -Peter Ehlers

Folkes, Michael wrote:
> hi all,
> It's not clear to me how (or if) I can pass multiple values for lty to a key in xyplot?
> I've tried:  lines=list(lty=1:3), to no avail.
> Do I need to use something other than auto.key?
> (Deepayan, if you're out there, I have your book and must admit the answer isn't jumping out at me.)
> thanks in advance!
> Michael Folkes
>  
> example code:
> #____________________________
>  
> xx<-data.frame(v1=rep(letters[1:3],rep(3,3)),v2=rep(1:3,3),v3=rep(1:3,rep(3,3)))
> xyplot(v3~v2,data=xx,
>   xlab='',
>   group=v1,type='l', lty=1:3  ,
> 
>    auto.key=list(text = levels(as.factor(xx$v1)) , title='',
>           cex.title=.75,points=F,lines = T,cex=1, x = .5, y = -0.1,corner = c(0, 0),
>           between=1,columns=3,between.columns=2),
>   )
> 
>  
> _______________________________________________________
> Michael Folkes
> Salmon Stock Assessment
> Canadian Dept. of Fisheries & Oceans     
> Pacific Biological Station
> 3190 Hammond Bay Rd.
> Nanaimo, B.C., Canada
> V9T-6N7
> Ph (250) 756-7264 Fax (250) 756-7053  Michael.Folkes at dfo-mpo.gc.ca <mailto:Michael.Folkes at dfo-mpo.gc.ca> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
> 
>




More information about the R-help mailing list