[R] lattice panle.segment()

From: Qian R <qianrstudy_at_yahoo.com>
Date: Mon, 28 Apr 2008 16:55:03 -0700 (PDT)


I am try to create a plot using xyplot(). I created a function panel.fun() wich generate segment, but I need use two columns from dataset2.    

  library(lattice)
  panel.fun <- function(x, y, minx, maxx, miny, maxy) {
  panel.xyplot(x,y)  

# since I don't know how to call dataset2 inside panel.fun(), so I hardcoded the data into function
  seq1 <-c(......)
  seq2 <-c(......)

  plotcols=rainbow(length(seq1))
    for(i in 1:length(seq1))
  {
  a <- seq1[i]
  b <- seq2[i]
  panel.segments(a,miny-rangey,a, maxy+rangey, col= plotcols[i],lty=4, lwd=2)   panel.segments(b,miny-rangey,b, maxy+rangey, col= plotcols[i],lty=4, lwd=2)     }
}    

# after create panel.fun, I call xyplot()
  xyplot(a ~ b , data=dataset1, auto.key=TRUE, panel=function(x,y, minx, maxx, miny, maxy, seq){  panel.fun(x,y, min(na.omit(x)), max(na.omit(x)),min(na.omit(y)),max(na.omit(y)))   })        

  Does anyone know how to solve this probelm?                



[[elided Yahoo spam]]

        [[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. Received on Tue 29 Apr 2008 - 00:00:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 Apr 2008 - 00:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive