[R] How to generate 'minor' ticks in lattice (qqmath)

Helmut Schütz helmut.schuetz at bebac.at
Wed Jan 24 13:41:29 CET 2007


Dear Gabor!

thanks for your hints; as a side-effect I learned a lot about lattice.

The working example is:

library("lattice")
library("grid")
numy <- 100
y <- runif(numy,min=0,max=1)
sig <- 0.05
numsig <- length(which(y<sig))

Lower <- 0
Upper <- 1
MajorInterval <- 5   # interval for major ticks
MinorInterval <- 4   # interval within major
Major <- seq( Lower,Upper,(Upper-Lower)/MajorInterval )
Minor <- seq( Lower,Upper,(Upper-Lower)/(MajorInterval*MinorInterval) )
labl <- as.character(Major)

trellis.focus("panel", 1, 1, clip.off = TRUE)
qqmath(y, distribution = qunif,
  prepanel = NULL,
  panel = function(x)
    {
    panel.abline(c(0,1), lty = 2)
    panel.polygon(c(0,0,numsig/numy,numsig/numy,0), c(0,sig,sig,0,0), 
lwd = 0.75)
    panel.qqmath(x, distribution = qunif, col = 1)
    },
    scales=list(x = list(at = Major), y = list(at = Major), tck=c(1,0), 
labels=labl, cex=0.9),
    xlab = "uniform [0,1] quantiles",
    ylab = "runif [0,1]",
    min = 0, max = 1)
trellis.focus("panel", 1, 1, clip.off = TRUE)
panel.axis("bottom", check.overlap = TRUE, outside = TRUE, labels = 
FALSE, tck = .5, at = Minor)
panel.axis("left", check.overlap = TRUE, outside = TRUE, labels = FALSE, 
tck = .5, at = Minor)
trellis.unfocus()

Best regards,
Helmut

-- 
Helmut Schütz
BEBAC
Consultancy Services for Bioequivalence and Bioavailability Studies
Neubaugasse 36/11
1070 Vienna/Austria
tel/fax +43 1 2311746
Web http://BEBAC.at
BE/BA Forum http://forum.bebac.at
http://www.goldmark.org/netrants/no-word/attach.html



More information about the R-help mailing list