2015-04-04 104 views
3

我想用嵌套因子制作nMDS数据图。我希望nMDS通过使用符号和颜色在一个图上显示这两个因素。你如何使一个因素显示为符号,另一个因素是nMDS(素食主义者)的颜色?

在此重现的实例中,如果被use嵌套在moisture,我想的情节,以显示作为Moisture不同的符号,然后Use为不同的颜色。

到目前为止,我已经想通了这一点:

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[,]论点的某个地方,但我不确定那些做的是什么。

回答

1

想通了来自这个问题修改答案: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