Skip to content

labelling graph axes: sub/superscript

4 messages · Oliver, Rebecca, Gavin Simpson, Crowe, Andrew

#
On Tue, 2009-07-28 at 12:09 +0100, Oliver, Rebecca wrote:
dat <- data.frame(x = rnorm(100), y = rnorm(100))
plot(y ~ x, data = dat,
     ylab = expression(italic(Anet) ~~ (mu*mol ~ m^{-2} ~ s^{-1}))) 

[the double ~~ is there to add a bit of extra spacing - the "t" looked
too close to the "(" with just one ~]

In these cases you are using plotmath, so reading ?plotmath is a must.
It contains a section on fonts and how to change them to different
families, but all font.lab does is switch between bold, plain italic
etc., which can all be done using things like italic() as documented
in ?plotmath.

Perhaps you can explain better with reproducible code what you want to
do or find annoying that is not covered in ?plotmath if the above
doesn't answer/help with the last part of your post?

HTH

G
#
Gavin Simpsons expression does not subscript ANET as in the original posters ytxt expression.  You could try the following to produce the subscripted label
 
ytxt=quote(italic(""*A[NET]*"")~"(umol  "*m^-2*" "*s^-1*")")
 
Andrew
 
Dr Andrew Crowe
 
Lancaster Environment Centre
Lancaster University
Lancaster    LA1 4YQ
UK
 
Tel: +44 (0)1524 595879

________________________________

From: r-sig-ecology-bounces at r-project.org on behalf of Gavin Simpson
Sent: Tue 28/07/2009 1:19 PM
To: Oliver, Rebecca
Cc: r-sig-ecology at r-project.org
Subject: Re: [R-sig-eco] labelling graph axes: sub/superscript
On Tue, 2009-07-28 at 12:09 +0100, Oliver, Rebecca wrote:
dat <- data.frame(x = rnorm(100), y = rnorm(100))
plot(y ~ x, data = dat,
     ylab = expression(italic(Anet) ~~ (mu*mol ~ m^{-2} ~ s^{-1})))

[the double ~~ is there to add a bit of extra spacing - the "t" looked
too close to the "(" with just one ~]

In these cases you are using plotmath, so reading ?plotmath is a must.
It contains a section on fonts and how to change them to different
families, but all font.lab does is switch between bold, plain italic
etc., which can all be done using things like italic() as documented
in ?plotmath.

Perhaps you can explain better with reproducible code what you want to
do or find annoying that is not covered in ?plotmath if the above
doesn't answer/help with the last part of your post?

HTH

G

--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk <http://www.freshwaters.org.uk/> 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
#
On Tue, 2009-07-28 at 13:39 +0100, Crowe, Andrew wrote:
Thanks for pointing that out Andrew, an oversight on my part.

The reason I missed it was that Rebecca was using (and repeated by
yourself above) a very convoluted way of expressing the axis label. As I
showed, none of this needs to be quoted with "", and all the "*" seem to
me to just confuse the matter. Also, note that Rebecca's code (and the
above) doesn't produce a \mu (micro symbol), where as the code in my
posting did.

Here is my suggestion again, this time rectifying the omitted
subscripting on NET.

dat <- data.frame(x = rnorm(100), y = rnorm(100))
plot(y ~ x, data = dat,
     ylab = expression(italic(A[NET]) ~ (mu * mol ~ m^{-2} * s^{-1})))

To my mind, the above label is much simpler and cleaner than using all
the "" and *, yet yields the same thing (except the mu/u difference).

HTH

G