[R] How to set axis labels?

Prof Brian D Ripley ripley@stats.ox.ac.uk
Tue, 2 Mar 1999 19:40:26 +0000 (GMT)


On Tue, 2 Mar 1999, Stuart Luppescu wrote:

> Sorry to bother everyone with such a basic question again, but I can't seem to
> set my axis labels. When I use
> title(ylab="String")
> "String" just overwrites the variable name, producing a mess. When I try to put
> ylab="String" in the plot function, like this:
> 
> plot(residuals(mschmod) ~ size94, ylab = "Productivity Adjusted for Context")
> I get this message:
> Error: formal argument "ylab" matched by multiple actual arguments

Ah, that is not `the plot function'. It is plot.formula, and I suggest you
use

plot(size94, residuals(mschmod), ylab = "Productivity Adjusted for 
Context")

For some reason plot.formula insists on setting ylab. I think it should be:

plot.formula <-
function (formula, data = NULL, subset, na.action,
          ylab=varnames[response], ..., ask = TRUE) 
{
    if (missing(na.action)) 
        na.action <- options()$na.action
    m <- match.call(expand.dots = FALSE)
    if (is.matrix(eval(m$data, sys.parent()))) 
        m$data <- as.data.frame(data)
    m$... <- NULL
    m[[1]] <- as.name("model.frame")
    mf <- eval(m, sys.parent())
    response <- attr(attr(mf, "terms"), "response")
    if (response) {
        varnames <- names(mf)
        y <- mf[[response]]
        if (length(varnames) > 2) {
            opar <- par(ask = ask)
            on.exit(par(opar))
        }
        for (i in varnames[-response]) plot(mf[[i]], y, xlab = i, 
            ylab = ylab, ...)
    }
    else plot.data.frame(mf)
}

Can anyone see why not?

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._