tests/methods.R

library(directlabels)
if(require(lattice) && require(nlme)){
  data(BodyWeight, package="nlme")
  oldopt <- lattice.options(panel.error=NULL)
  p <- xyplot(weight~Time|Diet,BodyWeight,groups=Rat,type='l',
              layout=c(3,1),xlim=c(-10,75))
  stop.if.same.colour <- function(d, ...){
    col.tab <- table(d$colour)
    if(1 == length(col.tab)){
      print(d)
      stop("only one colour")
    }
    d
  }
  dl <- direct.label(p, list("angled.boxes", "stop.if.same.colour"))
  print(dl)
  lattice.options(oldopt)
}
tdhock/directlabels documentation built on April 21, 2024, 11:32 a.m.