Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

r - Creating a superscript in mtext

I have the following dataframe

Data1 <- data.frame(pH = c(8,8.5,6,7.1,9), EC50 = c(20,11,5,25,50))
Data2 <- data.frame(pH = c(7,7.2,6.5,8.2,8.5), EC50 = c(13,15,18,25,19))

Using par I create two graphs on one plot:

par(mfrow=c(2,1), oma=c(3,3,1,1), mar=c(2,2,3,1), cex.axis=1.3)
plot(x=Data1[,'pH'], y=Data1[,'EC50'])
plot(x=Data2[,'pH'], y=Data2[,'EC50'])

Because I used par, I cannot specify the xlab and ylab in plot,
therefore I use mtext.
I would like to write a superscript in my ylab, however, I do not know how to do so,
when using mtext.

I have tried the following

mtext(expression("Cu^{2+} at EC50"), side=2, line = 4, padj=1, at=30, cex=1.2)

but can't seem to get the 2+ as a superscript above the Cu.

Any help is more than welcome!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
mtext(expression(paste("Cu"^"2+","at EC50",sep="")))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...