画带标准差的柱状图,除了barplot之外,还需要用到Hmisc包中的errbar。

x=read.table("correlation_coefficient_inter-class")
y=read.table("correlation_coefficient_between-class")
inter=mean(x[,1])
between=mean(y[,1])
y_mean=cbind(inter,between)
mp=barplot(y_mean,ylim=c(0,1),
           col = c(rgb(216,179,101,maxColorValue=255),rgb(90,180,172,maxColorValue=255)),
           beside=TRUE,space =c(0.1,0.7),width=c(0.1,0.1))
library(Hmisc)
cl=rgb(140,81,10,maxColorValue=255)
errbar(mp,y_mean,y_mean +c(sd(x[,1]),sd(y[,1])), y_mean - c(sd(x[,1]),sd(y[,1])),
       cap=0.035,errbar.col=cl,col=cl,lwd=3,add=T)
p=wilcox.test(x[,1],y[,1])$p.value
mtext(paste("p=",p),col=1, font=2, cex= 1.5)

注:mp能指定位置,将errbar画在柱子上。

【R作图】如何画带标准差的柱状图

相关文章:

  • 2022-12-23
  • 2021-04-15
  • 2021-12-25
  • 2021-11-01
  • 2021-08-25
  • 2021-11-01
  • 2021-11-01
  • 2022-12-23
猜你喜欢
  • 2021-09-16
  • 2021-09-10
  • 2021-08-29
  • 2021-04-01
  • 2022-12-23
  • 2022-02-26
  • 2021-07-26
相关资源
相似解决方案