如何更改R中较大句子中特定文本的颜色

时间:2017-04-22 17:35:56

标签: r plot

我想知道如何才能更改下面mtext()" 20%" 颜色

以下是我的情节图片( 请参阅图片下面的我的R代码 ):

enter image description here

这是我的R代码:

plot(1)

a = .3

b = .5

mtext(side = 3, bquote(bold("There is:"~ bolditalic(.(paste(round((b - a)*100, 2), "%",
    sep="")))~"probability that REAL effect size is equivalent to ZERO")),
    cex = 1.3, xpd =T)

2 个答案:

答案 0 :(得分:0)

它绝对不优雅,但如果你可以坚持固定的绘图宽度,它可以工作(调整adj)。

plot(1)
a = .3
b = .5

mtext(side = 3, line = 0.25, bquote(bold("There is:")), cex = 1.3, adj=0)
mtext(side = 3, line = 0.25, bquote(bolditalic(.(paste0(round((b - a)*100, 2), "%")))), cex = 1.3, col ='red', adj=0.1)
mtext(side = 3, line = 0.15, bquote(bold("probability that REAL effect size is equivalent to ZERO")), cex = 1.3, adj= 0.33)

答案 1 :(得分:0)

显然,这不是确切的科学。最后,以下内容对我有用:

plot(1)

a = .3 ; b = .5

mtext(side = 3, bquote(bold("There is:          probability that REAL effect size is equivalent to ZERO")), cex = 1.3, xpd =T) ## Notice the space

mtext(side = 3, bquote(bolditalic(~.(paste(round((b - a)*100, 2), "%",sep="")))), line = .18, 
  cex = 1.3, xpd =T, col = 'red', adj = .12) ## Notice the "~" sign

enter image description here