2015-04-04 34 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

相關問題