【问题标题】:Adding points to multiple boxplots向多个箱线图添加点
【发布时间】:2016-01-14 05:32:38
【问题描述】:

如何在多个不同长度的箱形图中添加点?

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() 

函数我不能添加多个,如果我将它们单独放入,它们将被添加到所有箱线图中,我只想看到相应的点。

【问题讨论】:

  • 您能添加一些数据并指出您想要实现的一些已知示例吗?我建议您 this 阅读如何制作可重现的示例
  • 您是否正在寻找类似的东西:boxplot(mpg ~ carb, data=mtcars); points(mtcars$carb, mtcars$mpg)。正如@PauloCardoso 所说,如果您提供与您的代码一起运行的示例数据,将会更容易为您提供帮助。

标签: r boxplot


【解决方案1】:

试试:

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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-29
    • 1970-01-01
    • 2016-01-26
    • 2021-10-28
    • 2018-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多