Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在nMDS(素食主义者)中,如何使一个因素显示为符号,另一个因素显示为颜色?_R_Data Visualization_Multi Dimensional Scaling - Fatal编程技术网

R 在nMDS(素食主义者)中,如何使一个因素显示为符号,另一个因素显示为颜色?

R 在nMDS(素食主义者)中,如何使一个因素显示为符号,另一个因素显示为颜色?,r,data-visualization,multi-dimensional-scaling,R,Data Visualization,Multi Dimensional Scaling,我试图用嵌套因子绘制数据的nMDS图。我希望国家导弹防御系统通过使用符号和颜色在一个图上显示这两个因素 在这个可复制的示例中,如果use嵌套在weather中,我希望绘图将weather显示为不同的符号,然后将use显示为不同的颜色 到目前为止,我已经明白了这一点: library("vegan") library("BiodiversityR") data(dune, dune.env) MDS <- metaMDS(dune, distance="bray", strata=dune

我试图用嵌套因子绘制数据的nMDS图。我希望国家导弹防御系统通过使用符号和颜色在一个图上显示这两个因素

在这个可复制的示例中,如果
use
嵌套在
weather
中,我希望绘图将
weather
显示为不同的符号,然后将
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)
library(“素食主义者”)
图书馆(“生物多样性”)
数据(沙丘,沙丘环境)

MDS通过修改这个问题的答案,找到了答案:

数据(dune,dune.env)
沙丘
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),)