[R] Minor Tick Marks in Lattice

Rene Braeckman RMan54 at cox.net
Thu Feb 22 06:08:39 CET 2007


I have a couple if issues with the code below.

1. as.Table=TRUE has no effect
2. the minor tick marks on top of the top panels are drawn in the strips and
not on the axes.

Any ideas what's wrong? There are probably better ways to add minor tick
marks...
Thanks for any help.
Rene

--------------------------------  
 
library(lattice)
Subj <- paste("Subj", rep(1:4,each=3))
Time <- rep(1:3,4) + 0.1
Conc <- (1:12) + 0.1
df <- data.frame(Subj,Time,Conc)
xScale <- 1:3
yScale <- list(1:3,4:6,7:9,10:12)
xMinorTicks <- seq(0.5,2.5,0.5)
 
xyplot(Conc ~ Time | Subj,
       data = df,
       layout = c(2,2),
       type="b",
       as.Table=TRUE,
       scales=list(
          x=list(at=xScale),
          y=list(at=yScale,relation="free"),
          alternating=3
       ),
       panel = function(x,y,...) {
          panel.abline(h=yScale[[panel.number()]], v=xScale,
col.line="gray")
          panel.xyplot(x,y,...)             
      }
)
 
# Add minor tick marks on bottom or top
for (coli in 1:2) {
  for (rowi in 1:2) {
    trellis.focus(name="panel", column=coli, row=rowi, clip.off = TRUE) 
    panel.axis(ifelse(rowi==1,"bottom","top"), 
      check.overlap = TRUE, outside = TRUE, labels = FALSE, 
      tck = .5, at = xMinorTicks)  
    trellis.unfocus()
  }
}



More information about the R-help mailing list