我希望离群值显示为与箱线图填充颜色相同的颜色(而不是轮廓线)。我尝试了不同的方法,但没有一个起作用。任何帮助将不胜感激。
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
p <- ggplot(ToothGrowth, aes(x=dose, y=len))+
geom_boxplot(width=0.3,aes(fill=dose),outlier.colour = NA)+
geom_point()+
scale_fill_manual(values=c("firebrick", "royalblue","yellow"))
p
我不确定您要寻找什么。也许这可以回答您的问题:
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
ggplot(ToothGrowth, aes(x=dose, y=len))+
geom_boxplot(width=0.3,aes(fill=dose), outlier.colour = NA)+
geom_point(aes(color=dose))+
scale_fill_manual(values=c("firebrick", "royalblue","yellow"))+
scale_color_manual(values=c("firebrick", "royalblue","yellow"))
为您提供