An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20090728/54c7eba7/attachment.pl>
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:
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 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
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
On Tue, 2009-07-28 at 13:39 +0100, Crowe, Andrew wrote:
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*")")
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
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
_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% 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 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%