Skip to content
Prev 11685 / 398502 Next

rotate ylab

Hi
trick,
The drawing of xlab and ylab ignores the par(las) setting.  This may seem
like an annoying thing for plot() to do, but there two points to make in its
defence:

(i)  plot() is a high-level function designed to try and provide sensible
default behaviour (and not to be too ridiculously complicated).  In the case
of drawing ylab and xlab, the only sensible (simple) general solution is to
draw them parallel to the axes because they can be very long and would
otherwise disappear off the edge of the plot or impinge on the plot data
region.

(ii)  you can override this "sensible" default behaviour if it annoys you.
For example, you can stop plot() drawing xlab and ylab by something like
plot(ann=F) or plot(xlab="", ylab="") AND you can draw them yourself using
mtext(), which does listen to par(las).
A couple of examples of what I mean ...

    par(mfrow=c(2,2), mar=c(5.1, 4.1, 4.1, 2.1), las=0)
    plot(0:10, 0:10, type="n")
    text(5, 5, "The default axes")
    box("figure", lty="dashed")
    par(las=1)
    plot(0:10, 0:10, type="n")
    text(5, 5, "The user says horizontal text please\n\nbut R knows better
!")
    box("figure", lty="dashed")
    par(las=1, mar=c(5.1, 6.1, 4.1, 2.1))
    plot(0:10, 0:10, type="n", ann=F)
    mtext("0:10", side=2, line=3)
    mtext("0:10", side=1, line=3)
    text(5, 5, "The user fights back !")
    box("figure", lty="dashed")

Anyway, whether you needed the philosophy or not, I hope that helps with
your example :)

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