R:如何在箱线图中共享标签名称?

R:如何在箱线图中共享标签名称?,r,label,boxplot,R,Label,Boxplot,我做了下面的图表 用命令 boxplot(tstats,names=c(expression(bar(x)),"","med(x)","","mad(x)","", var(x)","",expression(q[.75]-q[.25]),""), col=rep(c("wheat","chocolate"),5)) abline(h=2,col="steelblue",lty=2) abline(h=-2,col="steelblue",lty=2) tit

我做了下面的图表

用命令

boxplot(tstats,names=c(expression(bar(x)),"","med(x)","","mad(x)","",
         var(x)","",expression(q[.75]-q[.25]),""),
         col=rep(c("wheat","chocolate"),5))
abline(h=2,col="steelblue",lty=2)
abline(h=-2,col="steelblue",lty=2)
title(main="normal data")

但是我想把两个(小麦和巧克力)盒子的名字放在中间。如何修改第一个轴标签?

类似的操作可以满足您的需要:

##Some dummy data
dd = data.frame(values = rnorm(40), type=LETTERS[1:4])

##Don't plot the axes labels
##but add in the "plot frame"
boxplot(dd$values ~ dd$type, axes=FALSE, 
                  frame.plot=TRUE, ylim=c(-4, 4))

##Now add in the y-axis
axis(2, seq(-4,4,by=2))
##Add in the x-axis at points: 1.5 and 3.5
axis(1, c(1.5,3.5), c("Med", "Mad"))