Annotate 缩短以 0 结尾且不能用粗体书写的数字

Annotate shortens numbers which end with a 0 and can not be written in bold

大家好,这是这个问题的后续问题:

举个例子

library(ggplot2)
ggplot(mtcars, aes(mpg,disp)) +
annotate(geom = "text", x = 20, y = 300, label = bquote("R[m]^2 == 0.60"), parse = TRUE)

我希望代码写成 R²m = 0.60 而不是 R²m = 0.6 代码总是省略“0”,因为图中还有其他 R² 值,在点后面有第二个数字,所以没有 0 看起来很奇怪。 你知道我如何用粗体写这些东西吗?

非常感谢

您可以将 0.6 作为字符传递,并在 label 中使用 bold() 以获得粗体文本。

library(ggplot2)
ggplot(mtcars, aes(mpg,disp)) +
       annotate(geom = "text", x = 20, y = 300, 
                label = bquote("bold(R[m]^2 == '0.60')"), parse = TRUE)