capscale图上的颜色质心-素食主义者

时间:2020-10-25 06:21:22

标签: r plot colors vegan

我无法将用于数据点和图例的颜色应用于capscale图中的相应质心。由于某种原因,我得到了多个相同颜色的质心。 caps plot

colvec<- c("Maroon", "blue4", "chartreuse2", "coral", "brown", "burlywood2", 
"cadetblue", "black", "azure4", "orange", "chocolate", 
"gold","purple","darkolivegreen","darkkhaki")

mclean$Estuary<-as.factor(mclean$Estuary)
mod<-capscale(dmet~Estuary, data = mclean)
df<-data.frame(mod[["CCA"]][["centroids"]])

plot(mod, type = "n")
with (mclean, points(mod, display = "sites", col = colvec[mclean$Estuary], 
bg = colvec[mclean$Estuary]))
with(mclean, points(mod, display = c('cn'), scaling = 2, pch = 3, lwd=2, 
cex=1.5, col = colvec[mclean$Estuary], bg = colvec[mclean$Estuary]))  

legend('bottomright', c("Clarence River", "Georges River", "Hawkesbury 
River", "Hastings River", "Hunter River", "Macleay River", "Manning 
River","Ocean Zone 2", "Ocean Zone 3","Ocean Zone 4", "Ocean Zone 5",  "Port 
Stephens", "Richmond River", "Shoalhaven River",  "Wallis Lake"),  
text.col=c("Maroon", "blue4", "chartreuse2", "coral", "brown", "burlywood2", 
"cadetblue", "black", "azure4", "orange", "chocolate", 
"gold","purple","darkolivegreen","darkkhaki"), cex = .70)

我的数据如下:

dput(head(mclean,15))

structure(list(Estuary = structure(c(15L,6L,6L,13L,11L,4L, 11L,15L,13L,7L,13L,7L,6L,3L,3L),. Label = c(“ CLR”,“ GGR”, “ HKR”,“ HTR”,“ HUR”,“ MLR”,“ MNR”,“ OZ3”,“ OZ4”,“ OZ5”,“ PST”, “ RMR”,“ SHR”,“ TUL”,“ WLL”),类别=“因子”),X7Li_umol_molCa = c(2.693720415, 2.812779881,1.177200469,2.455601483,2.470483917,1.701062119, 2.157952819、2.649073116、1.779779735、3.4482489377、3.104093412, 2.470483917、2.779789748、2.217482552、2.723485282),X25Mg_umol_molCa = c(99.66512342, 65.19671613、89.76236276、154.1940588、98.51759322、50.61883241, 79.56209426、189.3849851、92.77994219、46.9637362、68.34179892, 127.800864、128.7358886、99.11260888、135.0260542),X55Mn_umol_molCa = c(0.295193632, 0.165458851、0.300834275、0.08531096、0.229386134、0.154177566, 0.086489854、0.385443914、0.2555709133,-0.018802142、0.122213924, 0.355360487、0.280151918、0.150417137、0.165458851),X88Sr_umol_molCa = c(1618.688479, 1829.719242、1601.004337、1234.353123、1662.309363、1496.078427, 1597.467508,1580.962309,1121.174613,2472.243074,1911.066296, 1486.646884、1384.007886、1531.446711、1552.66672),X138Ba_umol_molCa = c(1.042565345, 2.124997907、3.647474284、1.074158234、0.774777998、1.345706639, 0.883096475、0.764999247、0.49269863、0.77553021、1.114025452, 0.822919544、0.581459604、1.117034298、0.974866297),X115In_umol_molCa = c(0.00163741, 0.004048541、0.014214877、0.004145166、0.002788995,0.009176693, 0.007827179、0.006117795、0.018893191、0.006027827、0.005038184, 0.006747568,0.004498379,0.017993515,0.015924261)),row.names = c(NA, 15L),class =“ data.frame”)

和:

 dput(head(df,15))

结构(list(CAP1 = c(-0.0529332601372674,-0.00129788917790979, -0.0159618038755354,-0.00644899011465203、0.0739661951856259, -0.0193247691971371、0.0029113150730138、0.156116046382222、0.104734865900315, 0.0732969788117582、0.0560099029273388、0.0133695637185615,-0.0913418878728444, -0.0612009210422786,-0.00693425651785134),CAP2 = c(-0.00116613160672231, -0.0603871331756709、0.075594403585706,-0.116452288246655,-0.0810967750049817, 0.0124378421599932、0.0110725363439345,-0.102064222113947、0.0048753496982861, -0.0153400247748149、0.0561685021929774、0.0231876361798966, -0.0454728606069997、0.0787904240947763、0.113355484309807), CAP3 = c(-0.0817391532410816、0.0437660833401911、0.04009132559787, -0.0401422192388262,-0.0190094244733118、0.00417911504707151, 0.036010389926307、0.00749724900010081、0.0802116310565441, -0.0176689367575539,-0.00298220067834333,-0.172631982517045, 0.0513489284824863,-0.217196802166248、0.0430735742824018 ),CAP4 = c(0.00867314739873189,0.0167892576408617,0.0278423649968971, -0.173568704334081、0.154832695931103,-0.0824177039970023, -0.0247109368009962、0.00286418850813552,-0.0366318437737167, -0.0217294001655038,-0.022039624976774,-0.0326758822449291, 0.0184433628064148、0.117673727609336,-0.00358343081737813 ),CAP5 = c(0.0145851662085133,-0.0876574858761027,0.0318878154749647, 0.0715873684823734、0.0455892621677961、0.064903852550648, -0.0801990577548729,-0.00831860722397626,0.0150034749313496, 0.114626735611208,-0.0597519639040782,-0.119195379191939, -0.00803846048717321、0.03511200675435、0.0816982131694874 )),row.names = c(“ EstuaryCLR”,“ EstuaryGGR”,“ EstuaryHKR”, “ EstuaryHTR”,“ EstuaryHUR”,“ EstuaryMLR”,“ EstuaryMNR”,“ EstuaryOZ3”, “ EstuaryOZ4”,“ EstuaryOZ5”,“ EstuaryPST”,“ EstuaryRMR”,“ EstuarySHR”, “ EstuaryTUL”,“ EstuaryWLL”),class =“ data.frame”)

0 个答案:

没有答案