如果您只希望填充影响箱线图,请将aes()移动到箱线图中。任何 aes() 美学中的美学 ggplot() 呼叫本身将传播到所有层
aes()
ggplot()
ggplot(a, aes(x=Chick, y=weight)) + geom_boxplot(aes(fill=Diet), notch=F) + stat_summary(fun.y="mean", geom="point", shape=23, size=3, fill="white") + geom_text(data=xx, aes(x=level,y=1750,label = letter)) + xlab("Chick") + ylab("Weight")
你也可以禁用 fill= 文本层中的审美与 fill=NULL
fill=
fill=NULL
ggplot(a, aes(x=Chick, y=weight, fill=Diet)) + geom_boxplot(notch=F) + stat_summary(fun.y="mean", geom="point", shape=23, size=3, fill="white") + geom_text(data=xx, aes(x=level,y=1750,label = letter, fill=NULL)) + xlab("Chick") + ylab("Weight")