Adding points to multiple boxplots

被刻印的时光 ゝ 提交于 2019-12-01 11:24:28

问题


How would you add points to a several boxplots beside one another of varying lengths?

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)

If I put in something with

points() 

function I can't add in more than one and if I put them in separately they will be added to ALL the boxplots and I only want to see the corresponding points.


回答1:


Try:

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)



来源:https://stackoverflow.com/questions/33153951/adding-points-to-multiple-boxplots

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!