作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用嵌套因子制作 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),)
它会产生一个可爱的图,其中的符号和颜色正是我想要的:)
关于r - 如何在 nMDS(纯素)中使一个因素显示为符号,而另一个因素显示为颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29442699/
我是一名优秀的程序员,十分优秀!