[R-sig-eco] labelling graph axes: sub/superscript

Crowe, Andrew a.crowe at lancaster.ac.uk
Tue Jul 28 14:39:29 CEST 2009


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:
> Dear r list,
>
> I am having problems with superscripts and subscripts when labelling
> axes on graphs. I am trying to get the following label onto my y
> axis : Anet  (umol m-2 s-1). I am using the following code:
>
> >plot(SM,PN,pch=16,xlim=c(0,40),ylim=c(0,25),ylab=ytxt,xlab="soil
> moisture content (% vol.)",
> cex.lab=0.8,font.lab=1,bty="l",cex.axis=0.7,las=1)
> >ytxt=expression(""*A[net]*"  (umol  "*m^-2*" "*s^-1*")")
>
> Is it possible to get only Anet  in italics in this label?
> Additionally I find that the font.lab command does not work with axes
> containing sub/superscripts so you are forced to use all the default
> settings for you two axes to look the same. Does anyone know how I can
> correct this?

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



More information about the R-sig-ecology mailing list