How do I superscript the units this axis title. The ""
represent the parts that I need to be superscripted: Photosynthetically available radiation (µE m"-2"d"-1")
.
I have used the formula and having no luck so far:
plot(PAR~SST,data=brazilw, pch=15,col="red", main ="Fig. 1. Relationship between photosynthically available radiation\n and sea surface temperature",
ylab=expression("Photosynthetically available radiation (µE m"^-2~d^-1))
Whilst I don't see a real problem in this particular instance, I can see if being an issue with other labels. I tend to group the elements of the super/subscript in braces { }
, LaTeX stylee.
Here is an example:
plot(1:10,
ylab = expression("Photosynthetically available radiation" ~
(µE ~ m^{-2} ~ d^{-1})
)
)
There are gotchas with your version and the one above; the bit in the braces also needs to be a valid expression, hence
plot(1:10,
ylab = expression("Photosynthetically available radiation" ~ (µE ~
m^{2-} ~ d^{1-})))
fails with an error. (I sometimes need those forms for writing down formulae for ions for example). To solve this issue you really do need the braces { }
and you need something to come after the -
operator. This latter feature is handled by phantom()
, which leaves space in the expression for its argument, but as we won;t specify one, it is just a placeholder for nothing that can go on the right hand side of -
:
plot(1:10,
ylab = expression("Photosynthetically available radiation" ~ (µE ~
m^{2-phantom()} ~ d^{1-phantom()})))
phantom()
is also quite useful for placing a sub/superscript before a string, like you would with isotope notation
plot(1:10, ylab = expression(phantom()^{210} * Pb))
Two problems I see: There is not sufficient space for the superscripts on the margin and there is no closing right-paren. It's easy enough to add the closing paren with:
ylab=expression("Photosynthetically available radiation (µE m"^-2~d^-1*")"))
(You do need to quote the paren because it is "active" or "special" in expressions. Or you could use the plotmath group
-function. The margin is accessible with the par command or you could use the title command to specify a ylab that is closer to the plot:
plot(1,1, ylab="")
title(ylab=expression("Photosynthetically available radiation (µE m"^-2~d^-1*")"),
line=2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With