将轴标签添加到multcompview会对比图

时间:2013-05-07 19:39:03

标签: r

我一直在使用package multcompview能够根据anova和HSD tukey测试直观地显示组间的显着差异:

Group=c("G1","G1","G1","G1","G2","G2","G2","G2","G3","G3","G3","G3")
set.seed(0)
Vals=c(runif(4),runif(4)+0.7,runif(4)-0.7)
data=data.frame(Group)
data=cbind(data, Vals)  
library(multcompView)
xzx <-multcompBoxplot(Vals~Group,data=data,sortFn=median,  decreasing=FALSE,    
                  horizontal=FALSE,
                  plotList=list(
                    boxplot=list(fig=c(0,  1,  0,  1),  las=3,
                                 cex.axis=1.5),                      
                    multcompLetters=list(
                      fig=c(0.87,  0.97,  0.115,  0.923), #0.1108, 0.9432 Top of     
                      #page 18 manual for very convoluted explanation (c(y bottom, y top,x L, x R))
                      type='Letters') ) )

enter image description here

以下是我的一张实际图表的一个示例: enter image description here 这种方法(我在SO中发布相关问题后发现)效果很好,但我还没有找到一种能够添加y轴标签的方法(我需要标记Y变量“排名漏洞”)。 multcomp函数似乎没有接受ylab参数。 如果没有基本的轴标签信息,拥有这些整体美观的对比图是令人沮丧的...... 你知道这个问题的解决方案/解决方法吗?

2 个答案:

答案 0 :(得分:2)

我也试过这个很好的,但不是自我解释的包。 我发现当你想标记轴或主标题时,你必须在multcompBoxplot()之后启动title()。 例如:

title(ylab = 'Response', main = 'Title')

答案 1 :(得分:1)

在SO没有得到任何其他人的回复并且四处寻找各种复杂性的解决方案之后,我找到了一个效果很好且非常简单的方法(使用mtext):

Group=c("G1","G1","G1","G1","G2","G2","G2","G2","G3","G3","G3","G3")
set.seed(0)
Vals=c(runif(4),runif(4)+0.7,runif(4)-0.7)
data=data.frame(Group)
data=cbind(data, Vals)  
library(multcompView)
xzx <-multcompBoxplot(Vals~Group,data=data,sortFn=median,  decreasing=FALSE,    
                      horizontal=FALSE,
                      plotList=list(
                        boxplot=list(fig=c(0,  1,  0,  1),  las=3,
                                     cex.axis=1.5),                      
                        multcompLetters=list(
                          fig=c(0.87,  0.97,  0.115,  0.923), #0.1108, 0.9432 Top of     
                          #page 18 manual for very convoluted explanation (c(y bottom, y top,x L, x R))
                      type='Letters') ) )
mtext(side = 2, "Response", line = 2.3, cex=1.5)

enter image description here