向多个箱形图添加点 [英] Adding points to multiple boxplots

查看:96
本文介绍了向多个箱形图添加点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将点数添加到多个不同长度的箱形图上?

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)

如果我放入

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.

推荐答案

尝试:

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)

这篇关于向多个箱形图添加点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆