0

I'm performing a constrained ordination in the vegan package using CCA function. I have a matrix of species composition at various sites and a related environmental matrix.

invertcca<-cca(invert.rel~X100m, env)
plot(invertcca)

The default plot gives me both site and species scores, along with a vector displaying the environmental variable. It's messy, but here's what it looks like:

Default CCA plot

I was then playing around with customizing the plot. I got almost everything working except for adding the environmental vector back in. I did find a code for 'envfit' but I don't think it's right. It creates the arrow but in a different position than the plot above. I've included my code and an image below. Any suggestions?

colvec<-c("magenta", "seagreen", "deepskyblue")
fit <- envfit(invertcca~X100m, env)

plot(invertcca, main="Invert CCA", type="n")
with(env, points(invertcca,display="sites",col=colvec[Disturbance], cex=1.2, pch=21, bg=colvec[Disturbance]))
text(invertcca, display="species", cex=0.5, col="gray0")
with(env, legend("topright", legend=levels(Disturbance), col=colvec, pch=21, pt.bg=colvec))
plot(fit, cex=1.0, axis=TRUE)

Custom plot

Jérémie B
  • 10,611
  • 1
  • 26
  • 43

1 Answers1

1

From what I can tell, this might be related to your call for envfit. Try:

fit <- envfit(invertcca~100m,env,perm=999,display="lc")

I tried this using the varespec dataset in the vegan package and had the same problem until I followed the instructions in the example form the vegan manual.

data(varespec)
data(varechem)
ord <- cca(varespec~Al,varechem)
fit <- envfit(ord~Al,varechem,perm=999,display="lc")
plot(ord)

enter image description here

plot(ord,type="n")
plot(fit)
points(ord)

enter image description here

hope this helps

Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453
NDD
  • 64
  • 1
  • 11
  • Thank you so much! I'm new to R and this has been driving me crazy. It worked perfectly. :) – AquaticEcology Feb 26 '16 at 19:18
  • I am relatively new as well. It takes some getting used to. Looking over the vegan manual, it is the display="lc" code that you need in there to give total similarity to the CCA biplot by using the linear combination scores. – NDD Feb 26 '16 at 20:05