[R] extracting labels and axis info from plot

Paul Murrell p.murrell at auckland.ac.nz
Wed May 29 01:15:11 CEST 2002


Hi


> I would like to extract from a plot the text strings of the axis labels,
> and the ticks labels. I can get the extremes and step size for the ticks
> with par("yaxp"), but what about the axis labels?


The axis labels are not recorded in par() like the axis tick locations.

You could use the same function calls that the default plotting routines
use to determine default axis labels.  The following example does this
sort of thing ...

myplot <- function(x, y, xlab=NULL, ylab=NULL, ...) {
  if (is.null(xlab))
    xlab <- deparse(substitute(x))
  if (is.null(ylab))
    ylab <- deparse(substitute(y))
  plot(x, y, xlab=xlab, ylab=ylab, ...)
  list(xlab, ylab)
}
myplot(1:10, rnorm(10))

Hope that helps

Paul
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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