简体   繁体   English

将数据点添加到箱形图中

[英]adding data points to a box plot

Wondering if anybody can help up. 想知道是否有人可以帮忙。 We've created a box plot we're happy with showing the shannon index of different communities. 我们创建了一个箱形图,我们很乐意显示不同社区的香农指数。

The code we've used so far is: 到目前为止,我们使用的代码是:

wood <- c(1.2424533,1.3321779,1.0549202,2.0253262,0.7963116)
grass <- c(0.9743148,1.0397208,0.6931472,0,0.6365142)
scrub <- c(0,0.6365142,0.6931472,1.0397208,1.0986123,1.760146,
          1.4648164,0.6365142,1.2148897)

t.test(wood, grass, var.equal=T) ##t = -0.79206, df = 10, p-value = 0.4467 

t.test(wood, scrub, var.equal=T)

t.test(scrub, grass, var.equal=T)

lab <- c("Woodland","Grassland","Scrub")

boxplot(wood, grass, scrub, xlab="Treatment", ylab="Shannon Index", 
  col=c("darkolivegreen2", "darkolivegreen3", "darkolivegreen4")) 

posn <- c(1,2,3)
axis(side=1, at = posn, labels = lab) 

and now we want the points on top of each individual box plot in the same graph? 现在我们想要在同一张图中每个方框图上方的点吗?

Thank you in advance! 先感谢您!

Is this something like what you envisioned? 这是您所设想的吗?
The actual data-points are plotted on top of the box-plot. 实际数据点绘制在箱形图的顶部。

wood <- c(1.2424533, 1.3321779, 1.0549202, 2.0253262, 0.7963116)
grass <- c(0.9743148, 1.0397208, 0.6931472, 0, 0.6365142)
scrub <- c(0, 0.6365142, 0.6931472, 1.0397208, 1.0986123, 1.760146, 
          1.4648164, 0.6365142, 1.2148897)

gr <- list(Woodland=wood, Grassland=grass, Scrub=scrub)

bp <- boxplot(gr, xlab="Treatment", ylab="Shannon Index", outcex=0,
  col=c("darkolivegreen2", "darkolivegreen3", "darkolivegreen4")) 

points(stack(gr)[,2:1], pch=21, bg="grey")

带数据点的箱线图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM