我想知道如何更改 Tukey 的 HSD 绘图的轴,以便我可以缩短单词以使每个比较都合适而不显得荒谬。

如果您能帮助我更改轴标签、字体大小和颜色的代码,那将会很有帮助。

图中有很多比较,所以我想通过改变颜色来使重要的比较(间隔不在“0”线上的比较)更加突出。

`Gastropods = read.csv(file = "MaroubraZones.csv", header = TRUE)
boxplot(Abundance ~ Zone*Species,data = Gastropods, names = c("A.high", "A.mid", "A.low", "C.high", "C.mid", "C.low", "N.high", "N.mid", "N.low"))
Gastropods.ANOVA = aov(Abundance ~ Zone * Species, data = Gastropods)
hist(Gastropods.ANOVA$residuals)
plot(Gastropods.ANOVA)


Gastropods$LOGAbundance = log10(Gastropods$Abundance + 1)

Gastropods$SQRTAbundance = sqrt(Gastropods$Abundance + 1)

summary(Gastropods.ANOVA)
summary(Gastropods$SQRTAbundance.ANOVA)

interaction.plot(Gastropods$Zone, Gastropods$Species, Gastropods$Abundance, main= "Gastropod Interaction Plot", xlab = "Gastropod Zone", ylab= "Mean of Gastropod Abundance",legend = FALSE))

interaction.plot(Gastropods$Zone, Gastropods$Species, Gastropods$Abundance, main= "Gastropod Interaction Plot", xlab = "Gastropod Zone", ylab= "Mean of Gastropod Abundance", legend = FALSE)


TukeyHSD(Gastropods.ANOVA)
tuk<-TukeyHSD(Gastropods.ANOVA)
plot(tuk)`

正如您所看到的,轴很糟糕,我想突出显示零间隔之外的重要值。

最佳答案

试试这个:

TukeyHSD(Gastropods.ANOVA)
tuk<-TukeyHSD(Gastropods.ANOVA)
psig=as.numeric(apply(tuk$`Zone:Species`[,2:3],1,prod)>=0)+1
op=par(mar=c(4.2,9,3.8,2))
plot(tuk,col=psig,yaxt="n")
for (j in 1:length(psig)){
axis(2,at=j,labels=rownames(tuk$`Zone:Species`)[length(psig)-j+1],
     las=1,cex.axis=.8,col.axis=psig[length(psig)-j+1])
}
par(op)

你会有类似这个情节的东西

关于r - 在 Rstudio 中修改 Tukey HSD 95% 家庭级 CL 图,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30548217/

10-12 23:35