R plot中的mtext()

时间:2017-02-03 17:00:47

标签: r plot

我想知道mtext()有什么问题导致数字G无法正确显示在我的情节之上?

这是我的R代码:

G <- .3333 ## but G can be anything as it comes from a function

curve(dnorm(x),-3,3)
mtext(expression(paste("Medium: ",bold('CT'[12])," = ", round(G,2))),line=3)

1 个答案:

答案 0 :(得分:3)

您可以使用bquote.()(这用于在表达式中包含变量):

G <- 0.3333
curve(dnorm(x),-3,3)
mtext(bquote(paste("Medium: ",bold('CT'[12])," = ", .(round(G,3)))),line=3)

这给出了:

enter image description here