我想在 ggplot 中的文本中添加希腊字母。这是我的需求:
library(ggplot2)
df <- data.frame(x = rnorm(10), y = rnorm(10))
xIntercept <- mean(df$x)
yIntercept <- mean(df$y)
temp <- paste("theta = ", xIntercept) # This Works
ggplot(df, aes(x = x, y = y)) + geom_point() +
annotate("text", x = xIntercept, y = yIntercept, label = temp, color = "blue")
我想用希腊字母theta而不是"theta"。我尝试了这个链接,但无法实现。我尝试了以下代码但没有效果:
temp <- list(bquote(theta == .(xIntercept)))
temp <- bquote(theta == .(xIntercept))
temp <- expression(theta, "=", xIntercept)
temp <- c(expression(theta), paste0("=", xIntercept))
temp <- paste("theta == ", xIntercept)
会保留等号。 - MrFlick