2

我做了下面的图表在此处输入图像描述

用命令

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

但我想将两个(小麦和巧克力)盒子之间的共享名称居中。如何修改第一个轴标签?

4

1 回答 1

5

这样的事情应该做你想做的事:

##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"))
于 2012-03-25T20:49:46.997 回答