我们可以使用boxplot
的不可见输出来得到中值和ns.对于面板下方的中间标签和桌状对象,我们可以使用text
和mtext
函数以及lines
.我们最好使用png
设备.
png('myplot.png', 600, 400)
par(mar=c(7, 4, 4, 2)+.1)
b <- boxplot(val ~ let, data=exampledf, xlab='', las=1)
mds <- b$stats[3, ]
text(1:3, mds + .225, labels=formatC(mds,format='f', digits=2), cex=.8)
mtext(c('n', b$n), 1, 2.5, at=c(.5, 1:3)-.05, adj=0)
mtext(c('median', formatC(mds,format='f', digits=2)), 1, 3.5, at=c(.5, 1:3)-.05, adj=0)
lines(c(.75, 3.25), c(-.25, -.25), xpd=TRUE)
lines(c(.75, 3.25), c(-1.5, -1.5), xpd=TRUE)
mtext('let', line=1)
dev.off()