1
這裏我將colorRed
設置爲TRUE
,因此文本爲紅色。但是,當我將其設置爲FALSE
時,顏色仍爲紅色。geom_text中的條件文本顏色,scale_color_manual
如何使文本顏色條件的值爲colorRed
?
library(ggplot2)
ann_text = data.frame(x = 1.5, y = max(mtcars$mpg), LABEL = "TEXT", colorRed = FALSE)
ggplot(mtcars, aes(x = factor(am), y = mpg)) + geom_boxplot() +
geom_text(data = ann_text, aes(x = x, y = y, label = LABEL, color = colorRed)) +
scale_color_manual(values = c('red', 'black'), guide = "none")