I'm wondering how to boldface the entire phrase: " 95% CI: [number 1 , number 2 ] " as a legend in my plot below? ( Note: "number 1" and "number 2" are specified in my code below).
Here is my R code which requires a fix:
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 If I omit the bold()
part from the code, the entire phrase shows normally, but I loose the bolding effect.
Two options/workarounds:
You can bold()
each literal string individually, but I don't know how to bold the dynamic portions (eg, .(round(.4432,3))
). This would look like:
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))
The numbers are not bold.
With this label/legend, you don't actually need bquote
, so you can use the text.font
option of legend
to bold the whole string:
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)
The disadvantage with this is that you are you able to use math symbols.
The text.font
is a legend
-specific argument for the more-generic font
parameter, found in ?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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.