问题
Admittedly I am new to R but I have looked around quite a bit and I can't seem to solve this.
For superscript this works lovely
mtext(expression(paste( italic("h") ^ italic("2"))), side=2, line = 2, cex=cexm)
but when I try to get a subscript using the same approach
mtext(expression(paste(italic("I") [] italic("a"))),side=2, line=2,cex=cexm)
or
mtext(expression(paste(italic("I"), italic(["a"]))),side=2, line=2,cex=cexm)
plus several other variations on this theme
R keeps telling me that there is an unexpected [
Any help would be greatly appreciated, apologies if this is addressed elsewhere but I did not succeed in finding it.
回答1:
In the first instance the paste call is entirely superfluous since the argument is a valid R expression:
mtext(expression( italic("h") ^ italic("2")), side=2, line = 2) # works
In the second instance paste
is also unnecessary:
mtext(expression( italic("I") [italic("a")] ),side=2, line=2,cex=cexm)
The argument to the plotmath-"[" function needs to be inside the paired "[]"
-symbols.
来源:https://stackoverflow.com/questions/28664385/include-formatted-subscript-in-mtext