ここでは、テキストが赤になるように設定colorRed
します。TRUE
しかし、に設定するとFALSE
、色はまだ赤です。
の値に基づいてテキストの色を条件付きにする方法は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")