gpt4 book ai didi

r - 在 Rstudio 中修改 Tukey HSD 95% 系列 CL 图

转载 作者:行者123 更新时间:2023-12-01 22:34:54 24 4
gpt4 key购买 nike

我想知道如何改变 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)`

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

enter image description here

最佳答案

试试这个:

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)

你将会得到与此情节类似的内容 enter image description here

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com