[R] sub- and superscript in plot labels

Gavin Simpson gavin.simpson at ucl.ac.uk
Thu Nov 4 13:20:23 CET 2004


Dear List,

I need to add a subscript and a superscript to some of the ions in the 
labels on some plots.

I have got to here but now I'm stuck:

plot(1:10, xlab = expression(paste("nm SO"[4], " ", mu, "eq cm"^{-2}, " 
yr"^{-1})))

Which gives almost  what I require. No matter what I tried, however, I 
could not get bot a sub script *and* a superscript attached to the SO in 
the label.

In LaTeX I would just do $SO_4^{2-}$ but taking that to R produces a 
syntax error:

plot(1:10, xlab = expression(paste("nm SO"[4]^{2-}, " ", mu, "eq 
cm"^{-2}, " yr"^{-1})))

Strangely, I can do this:

plot(1:10, xlab = expression(paste("nm SO"[4]^2, " ", mu, "eq cm"^{-2}, 
" yr"^{-1})))

With almost the desired effect (except I need to add two characters to 
the superscript).

Can any one offer a solution?

Many thanks

Gavin
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson                     [T] +44 (0)20 7679 5522
ENSIS Research Fellow             [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC                 [E] gavin.simpson at ucl.ac.uk
UCL Department of Geography       [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way                    [W] http://www.ucl.ac.uk/~ucfagls/
London.  WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list