R - boxplot with multiple factor labels

雨燕双飞 提交于 2019-11-30 09:23:37

FWIW, a ggplot2 solution:

library(ggplot2)
ggplot(data = d, aes(x = f1, y = x)) + 
  geom_boxplot(aes(fill = f2), width = 0.8) + theme_bw()

If you want a label at the middle of each group of 3 boxes, try something like this:

axis(1,at=seq(2,60,3),labels=1:20,cex.axis=0.7)

To generalise, this would be:

groups <- 20
numbox <- 3
total <- groups * numbox
xpoints <- seq(median(1:numbox),total,numbox)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!