When parse = FALSE
the annotation (see reprex below) appears in bold, as expected since fontface = "bold"
; however, when parse = TRUE
the annotation no longer appears in bold. Can anyone suggest a fix for this please?
library(ggplot2)
df <- data.frame(
a = c(1, 2),
b = c(1, 2)
)
mean <- mean(df$a)
stdev <- sd(df$a)
f <- paste0(mean, '* "±" * ', stdev, ' ~ "kg" * "\U00B7" * yr^-1')
ggplot(df) +
annotate(
"text",
x = 55,
y = 43.2,
label = f,
fontface = "bold",
parse = FALSE
)
Original reprex from Adding a value to an expression and pasting it in ggplot2 with annotate ; thanks to Stefan.