My routine (below) works OK but misbehaves if the on-screen plot is made wider using the mouse.
The problem is caused by using par("usr")[1] - 0.07 * (par("usr")[2] - par("usr")[1]) to locate two items on the y-axis. The rest of the labeling is controlled by the "line=0" parameter setting. Of course resizing changes the absolute plot width, and I'd rather have things with respect to the line= setting. (Try it: Cut and paste the code, then resize the screen plot to be wider.) Is there another way to do what I'm trying to do? I'm using R version 2.11.1 (2010-05-31), running on an HP 64 bit Windows 7 machine. Thanks ############################################ four.nines.cartesian.probability.grid <- function (X.data, x.title = "X", y.title = "Theoretical Normal CDF", X.start, X.end) { probs <- c(0.0001, 0.0003, 0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.98, 0.99, 0.995, 0.998, 0.999, 0.9997, 0.9999) z.vals <- qnorm(probs) y.min <- z.vals[1] y.max <- z.vals[length(z.vals)] npts <- length(X.data) X.mean <- mean(X.data) X.sd <- sd(X.data) X.001 <<- X.mean + X.sd * qnorm(0.001) X.999 <<- X.mean + X.sd * qnorm(0.999) plot(NA, axes = FALSE, xlim = c(X.start, X.end), ylim = c(qnorm(0.0001), qnorm(0.9999)), xlab = "", ylab = "") axis(side = 1, labels = TRUE, at = pretty(c(X.001, X.data, X.999), n=8), line = 0, tick = TRUE, outer = FALSE) mtext(text = x.title, side = 1, line = 2.3, adj = 0.5) axis(side = 2, at = z.vals, labels = c(NA, NA, as.character(probs)[-(1:2)]), line = 0, tck = -0.01, las = 1, cex.axis = 0.8) x.loc <- par("usr")[1] - 0.07 * (par("usr")[2] - par("usr")[1]) ## If plot is resized wider this may be troublesome. text(x = x.loc, y = z.vals[1], bquote(1*" X "*10^-4), cex = 0.75, xpd = TRUE) text(x = x.loc, y = z.vals[2], bquote(3*" X "*10^-4), cex = 0.75, xpd = TRUE) abline(h = qnorm(c(0.90, 0.95, 0.99, 0.999, 0.9999)), lty = 5, col = "gray") abline(h = qnorm(c(0.10, 0.05, 0.01, 0.001, 0.0001)), lty = 5, col = "gray") mtext(text = y.title, side = 2, line = 3, at = (y.max + y.min)/2, adj = 0.5) mtext("www.StatisticalEngineering.com", side = 1, line = 2.9, adj = 1, cex = 0.7) box() } ############################################ windows(width = 6, height = 6, pointsize = 12) par(mar = c(4, 4, 0.5, 1) + 0.1) X.data <- rnorm(n=100, mean = 8000, sd = 300) four.nines.cartesian.probability.grid(X.data, X.start = 7000, X.end = 9000) points(x = sort(X.data), y = qnorm((((1:length(X.data)) - 0.5)/length(X.data)))) ############################################ Charles Annis, P.E. charles.an...@statisticalengineering.com 561-352-9699 http://www.StatisticalEngineering.com ______________________________________________ R-help@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.