[R] How to set axis labels?

Ross Ihaka ihaka at stat.auckland.ac.nz
Tue Mar 2 20:45:31 CET 1999


Some of the functions don't seem to allow plot labels to be overridden
In the case of plot.lm you can redefine it as follows:

"plot.lm" <-
function (x, xlab = "Fitted values", ylab = "Residuals",
          main = paste("Tukey-Anscombe plot of", deparse(x$call)), ...)
{
    if (!any(class(x) == "lm"))
        stop("Use only with 'lm' objects")
    r <- residuals(x)
    yh <- fitted(x)
    hii <- lm.influence(x)$hat
    if (prod(par("mfcol")) < 2 && interactive()) {
        op <- par(ask = TRUE)
        on.exit(par(op))
    }
    plot(yh, r, xlab = xlab, ylab = ylab, main = main, ...)     
    abline(h = 0, lty = 3, col = "gray")
    qqnorm(r/sqrt(1 - hii), ylab = "Standardized Residuals")
}   

Note that this only changes the labels residuals vs y-hat plot,
not in the normal plot.

One of the nice features of this kind of software is that you can
modify the default functions to meet your own needs.

	Ross

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list