如何在不同长度的彼此旁边的几个箱图中添加点?
boxplot(box1, box2, box3, box4, beside=T, col=c("grey100", "grey70", "grey50", "grey70"), names=c("box1", "box2", "box3", "box4"), main="all the boxes", las=2)
如果我用
输入内容points()
功能我不能添加多个,如果我将它们单独放入,它们将被添加到所有的箱图中,我只想看到相应的点。
答案 0 :(得分:2)
尝试:
ndata=mtcars[mtcars$carb%in%c(1:4),]
boxplot(mpg ~ carb, data=ndata
, beside=T,
col=c("grey100", "grey70", "grey50", "grey70"),
names=c("box1", "box2", "box3", "box4"),
main="all the boxes", las=2)
points(factor(ndata$carb), ndata$mpg,col=3)
points(3,30,col=4,pch=13)
text (3.5,30,"Oops",pos = 4)