[R] Lattice --reference line in panels does not come up
Douglas Bates
bates at stat.wisc.edu
Wed Feb 16 15:00:04 CET 2005
Uwe Ligges wrote:
> 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()
> }
> )
Or, in recent versions of the lattice package,
xyplot(..., type = c("g", "p"))
More information about the R-help
mailing list