[R] Lattice --reference line in panels does not come up

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Feb 16 14:21:27 CET 2005


Luis Ridao Cruz wrote:

> R-help,
> 
> I am quite new to lattice.
> I am plotting something in which I want some reference lines.
> I do the foolowing :
> 
> library ( lattice )
> reference.line <- trellis.par.get ( "reference.line" ) 
> reference.line$lty <- 2    ## not working with any of the
> reference.line components
> # reference.line$col <- "red" 
> trellis.par.set("reference.line", reference.line)
> xyplot ( number ~ cm | year , data = lgda., type = "l", col = "black" ,
> ylab = "Number", xlab = "Length (cm) ") ## the actual plot
> 
> The result is without reference lines.
> 
> What am I doing wrong?


You have forgotten to specify panel.grid() in your call, which is the 
only function accepting reference line settings, AFAIK. The following 
should do the trick:

  xyplot(.....,
    panel = function(x, y, ...){
      panel.xyplot(x, y, ...)
      panel.grid()
    }
  )



Uwe Ligges




> 
> Thanks in advance
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list