Skip to content
Prev 7460 / 63424 Next

expressions as axis labels

[moved to R-devel]
Thomas Lumley wrote:
That change indeed is reasonable, but I don't think it is this
particular change (at least as documented) that makes Patrick's example
doesn't work any more.
Right for text() and friends, but not for axis(), see the example below,
and maybe this is a bug (Paul?). Anyway, fixing this bug (?) won't
change much for Patrick's example.
If sub- or superscripts are a expression, space is added below
respective above that expression (if not already done before), so
complex formulas can be generated. And, at least for me, the result is
somehow expected.

I am very surprised and wondered why Patrick's example worked in
R-1.4.1.
Without having looked into the code, there must have been something
fuzzy that is broken since R-1.5.0.
Here an example on the alignments:

 plot(1:12, type="n", axes=FALSE)

 expr <- expression(F^{-''}, Cl^{-''}, NO[2]^{-''}, NO[3]^{-''}, 
    PO[4]^{3-''}, SO[4]^{2-''}, Na^{+''}, NH[4]^{+''}, K^{+''},
    Mg^{2+''}, Ca^{2+''}, H^{+''})

 axis(1, 1:12, lab=expr)  # the "problem"

 text(1:12, 3, expr) # adj=c(0.5, 0.5), the default for text()

# This looks like the x-axis annotation:
 text(1:12, 5, expr, adj=c(0.5, 0)) 

# And this is all in *one* formula, as Patrick would like to get it
somehow.
# Only a guess: Was there something like a "coerce to one formula" in
R-1.4.1?

 text(6, 9, 
    labels = expression(F^{-''} * Cl^{-''} * NO[2]^{-''} * NO[3]^{-''} * 
    PO[4]^{3-''} * SO[4]^{2-''} * Na^{+''} * NH[4]^{+''} * K^{+''} *
    Mg^{2+''} * Ca^{2+''} * H^{+''}))


I am sure, Paul will get the point in less than a second.

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