Luis Ridao Cruz
2005-Feb-16 12:26 UTC
[R] Lattice --reference line in panels does not come up
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? Thanks in advance
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
Luis Ridao Cruz
2005-Feb-16 13:24 UTC
[R] Lattice --reference line in panels does not come up
Thank you Uwe, It worked ! Luis>>> Uwe Ligges <ligges at statistik.uni-dortmund.de> 16/02/2005 13:21:27 >>>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
Douglas Bates
2005-Feb-16 14:00 UTC
[R] Lattice --reference line in panels does not come up
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"))