## Draw a plot for a non-vegan ordination (cmdscale).
data(dune)
dune.dis <- vegdist(wisconsin(dune))
dune.mds <- cmdscale(dune.dis, eig = TRUE)
dune.mds$species <- wascores(dune.mds$points, dune, expand = TRUE)
pl <- ordiplot(dune.mds, type = "none")
points(pl, "sites", pch=21, col="red", bg="yellow")
text(pl, "species", col="blue", cex=0.9)
if (FALSE) {
## same plot using pipes (|>)
ordiplot(dune.mds, type="n") |>
points("sites", pch=21, col="red", bg="yellow") |>
text("species", col="blue", cex=0.9)
## Some people think that species should be shown with arrows in PCA.
## Other ordination methods also return an invisible ordiplot object and
## we can use pipes to draw those arrows.
mod <- rda(dune)
plot(mod, type="n") |>
points("sites", pch=16, col="red") |>
text("species", arrows = TRUE, length=0.05, col="blue")
}
## Default plot of the previous using identify to label selected points
if (FALSE) {
pl <- ordiplot(dune.mds)
identify(pl, "spec")}
Run the code above in your browser using DataLab