[英]Boldfacing Plot Legend with words, numbers, and symbols in R
我想知道如何将整个短语:“ 95%CI:[数字1,数字2] ” 加粗为我下面的情节中的图例? ( 注意: “数字1”和“数字2”在下面的代码中指定)。
这是我的R代码 ,需要修复:
plot(1:10,ty="n",bty="n")
legend("topleft", legend=bquote(paste(bold("95% CI: [ ", .(round(.4432, 3)),
", " , .(round(.0034, 3))," ]"))),
bty="n", inset=c(0,.03))
PS:如果我从代码中省略了bold()
部分,则整个短语都可以正常显示,但是我失去了加粗效果。
两种选择/解决方法:
您可以分别对每个文字字符串执行bold()
,但是我不知道如何对动态部分进行加粗(例如.(round(.4432,3))
)。 看起来像:
plot(1:10,ty="n",bty="n") legend("topleft", legend=bquote(paste(bold("95% CI: [ "), .(round(.4432, 3)), bold(", ") , .(round(.0034, 3)), bold(" ]"))), bty="n", inset=c(0,.03))
数字不是粗体。
有了这个标签/传说,你实际上并不需要bquote
,这样你就可以使用text.font
的选项legend
大胆整个字符串:
plot(1:10,ty="n",bty="n") legend("topleft", legend=paste("95% CI: [ ", round(.4432, 3), ", " , round(.0034, 3), " ]"), bty="n", inset=c(0,.03), text.font=2)
这样做的缺点是您可以使用数学符号。
text.font
是更常见的font
参数的legend
专用参数,可在?par
找到:
'font' An integer which specifies which font to use for text. If
possible, device drivers arrange so that 1 corresponds to
plain text (the default), 2 to bold face, 3 to italic and 4
to bold italic. Also, font 5 is expected to be the symbol
font, in Adobe symbol encoding. On some devices font
families can be selected by 'family' to choose different sets
of 5 fonts.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.