我可以在ggplot2圖例中使用下標嗎?我看到this question在傳說和其他地方的希臘字母,但我無法弄清楚如何適應它。如何在ggplot2圖例中使用下標[R]
我認爲使用expression()
,它在軸標籤工作,將做的伎倆。但我下面的嘗試失敗了。謝謝!
library(ggplot2)
temp <- data.frame(a = rep(1:4, each = 100), b = rnorm(4 * 100), c = 1 + rnorm(4 * 100))
names(temp)[2:3] <- c("expression(b[1])", "expression(c[1])")
temp.m <- melt(temp, id.vars = "a")
ggplot(temp.m, aes(x = value, linetype = variable)) + geom_density() + facet_wrap(~ a)
' 「表達(B [1])」'將作爲字符,而不是表達來治療。 – chl 2011-06-01 14:33:50