几个小时后我还没有在网上找到任何解决方案。我希望异常值与盒子颜色相同。
outlier.colour = NULL
不起作用。这是代码。这应该像使用outcol和outbg参数传递par语句一样简单。我还看到一个帖子为" scale_colour_manual添加了相同的颜色相同的参数,但这也不起作用。
library(datasets)
t <- ggplot(airquality, aes(factor(Month), Ozone))
t + geom_boxplot(aes(fill=factor(Month)), outlier.size = 2, outlier.color = NULL) +
scale_fill_manual(name = "Ozone Levels Per Month", values = c("pink", "green", "orange", "yellow", "blue"))
答案 0 :(得分:1)
异常值继承了线条的颜色,而不是填充颜色。
t + geom_boxplot(aes(fill=factor(Month), color = factor(Month)), outlier.size = 2) +
scale_fill_manual(name = "Ozone Levels Per Month", values = c("pink", "green", "orange", "yellow", "blue")) +
scale_color_manual(name = "Ozone Levels Per Month", values = c("pink", "green", "orange", "yellow", "blue")) +
geom_boxplot(aes(fill=factor(Month)), outlier.size = 2, outlier.colour = NA) #if you want grey lines