1
Hier setze ich colorRed
zu TRUE
, so dass der Text rot ist. Aber wenn ich es auf FALSE
einstelle, ist die Farbe immer noch rot.Bedingte Textfarbe in geom_text, scale_color_manual
Wie wird die Textfarbe vom Wert colorRed
abhängig gemacht?
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")