[R] Re: trivial axis question?

Jim Lemon bitwrit at ozemail.com.au
Thu Apr 22 14:39:38 CEST 1999


Armin,

Here is the bare-bones routine for doing staggered labels.

staxlab <- function (xticlabels, ypos)
{
    if (!missing(xticlabels)) {
        if (missing(ypos)) {
            yrange <- par("usr")[3:4]
            ypos <- c(yrange[1] - (yrange[2] - yrange[1])/22,
                yrange[1] - (yrange[2] - yrange[1])/12)
        }
        axis(1, 1:length(xticlabels), rep("", length(xticlabels)))
        text(1:length(xticlabels), ypos, xticlabels)
    }
    else cat("Usage: staxlab(xticlabels [,ypos])\n")
}

Try this  for a basic test:

> plot(1:10,xaxt="n")
> staxlab(rep("Testing123",10))

The default 'ypos' will usually squeeze the staggered labels in, but you
may wish to pass specific values for 'ypos' and perhaps even adjust the
X-axis label by increasing the space
at the bottom of the plot;

>par(mar=c(6,4,4,2))    or (7,4,4,2)...

not letting 'plot' print an X-axis label;

>plot(...,xlab="",...)

printing an X-axis label below where it would normally be;

>text(5,-1.5,"Index")

and finally spreading out the tick labels;

> staxlab(rep("Testing123",10),c(0,-0.5))


Looking at your other questions, I suspect that part of your problem may
be your system.  I can't reproduce the errors on either of my Linux
systems, both running R v0.63.2.  I think I recall someone having
problems with the Postscript output on the Windows version of R 0.63.
Note that I've tested 'staxlab' on both of my systems as well.

Jim


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