您将如何将点添加到多个不同长度的箱线图中?
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)
Run Code Online (Sandbox Code Playgroud)
如果我放入一些东西
points()
Run Code Online (Sandbox Code Playgroud)
功能我不能添加多个,如果我将它们分开放置,它们将被添加到所有箱线图中,我只想看到相应的点。
尝试:
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)
Run Code Online (Sandbox Code Playgroud)