0

I have run RDA from Vegan, and cannot generate four different colors in the "sites" on the plot that correspond to the Group trait which really is countries. The problem is colvec[Group] that fails to link up the four colors with the four different countries. I avoided this for the legend by just spelling out the colors for each country, and that worked (produced a legend with the correct colors for the country). When I take out the col = colvec[Group], the plot does produce the points ("sites"), but they all are black in color and do not differentiate the countries. I have been using the suggested code at: https://fromthebottomoftheheap.net/2012/04/11/customising-vegans-ordination-plots/

Can anyone help suggest a modification that would produce the correct colors in the points (sites)?

Thanks much.

plot(R EDUNENVONLY)
scl <- 2
par(pty="s")  #makes plot square
colvec <- c("dark green", "red", "purple", "blue")
Group <- ENVIR$Group
plot(REDUNENVONLY, choices = c(1, 2), type = "n", xlim = c(-1.5, 1.5)) 
with(ENVIR, points(REDUNENVONLY,  display = "sites", 
 bg = colvec[Group], col = colvec[Group],
                            scaling = scl,  pch = 21))
text(REDUNENVONLY, display="bp", scaling = scl, cex = 1,col=1) # add black arrows
with(ENVIR, legend("topright", legend = c("CCHINA", "JAPAN", "KOREA", "NCHINA"),
col = c("dark green", "red", "purple", "blue"), pch = c(16,16)))



[![Biplot produced from code above](https://i.stack.imgur.com/zTqHW.png)](https://i.stack.imgur.com/zTqHW.png)

[![Biplot without col = colvec[Group] ](https://i.stack.imgur.com/G4XjU.png)](https://i.stack.imgur.com/G4XjU.png)

I have tried various other solutions, and I know ggplot is another possibility, but this would require more learning (I am a novice at R) and surely some simply change to the present code will get this to work.

0 Answers0