gpt4 book ai didi

r - 如何在 nMDS(纯素)中使一个因素显示为符号,而另一个因素显示为颜色?

转载 作者:行者123 更新时间:2023-12-01 23:18:11 27 4
gpt4 key购买 nike

我正在尝试使用嵌套因子制作 nMDS 数据图。我希望 nMDS 通过使用符号和颜色在一张图上显示这两个因素。

在这个可重现的示例中,如果 use 嵌套在 moisture 中,我希望绘图将 Moisture 显示为不同的符号,然后使用作为不同的颜色。

到目前为止我已经弄清楚了:

library("vegan")
library("BiodiversityR")

data(dune, dune.env)
MDS <- metaMDS(dune, distance="bray", strata=dune.env$Moisture)
MDS

plot(MDS$points[,2], MDS$points[,1], type="n", main="Communities by Use",
xlab="NMDS Axis 1", ylab="NMDS Axis 2", xlim=c(-1.5,1.5), ylim=c(-1.5,1.5))
ordisymbol(MDS, dune.env, factor="Use", cex=1.25, rainbow=T, legend=T)

这给了我不同的符号和颜色的不同用途,但没有显示任何关于湿度的信息。是否可以让它显示不同的因素?我假设它可能位于 MDS$points[,] 参数中的某个位置,但我不确定它们到底在做什么。

最佳答案

通过修改这个问题的答案来解决这个问题:Plot points of metaMDS

data(dune, dune.env)
dune.MDS <- metaMDS(dune, distance = "bray", strata=dune.env$Moisture)
dune.MDS

pchs<- c(0:5)
gr.moi <- factor(dune.env$Moisture)
gr.use <- factor(dune.env$Use)
col.gr <- c("red", "blue", "purple")


plot(dune.MDS, type = "n", display = "sites")
orditorp(dune.MDS,display="species",col="dark grey",air=0.01)
points(dune.MDS, display = "sites", pch = pchs[gr.moi], col = col.gr[gr.use])
legend("topright", legend=levels(gr.moi), bty = "n", col= c("black"), pch = pchs)
legend("bottomright", legend = levels(gr.use), bty = "n", col = col.gr, pch=c(20),)

它会产生一个可爱的图,其中的符号和颜色正是我想要的:) Nested nMDS showing both factors

关于r - 如何在 nMDS(纯素)中使一个因素显示为符号,而另一个因素显示为颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29442699/

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