Search code examples
rggplot2vegan

Label individual points with ordiplot3d?


Is there any way to add individual point labels in an ordiplot3d plot? Example using package data below.

3D plot of the data

library(vegan3d)
library(ggplot2)


data(dune, dune.env)
SITE_ID <- c("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t")
dune.env$SITE_ID <- SITE_ID
ord <- cca(dune ~ A1 + Moisture, dune.env)
ordiplot3d(ord)
pl4 <- with(dune.env, ordiplot3d(ord, col = Management, pch=16,angle=50))
with(dune.env, ordihull(pl4, dune.env$Management, draw = "poly", col = 1:4,label=T,
                    alpha = 50))

Solution

  • This should work!

    sp <- scores(pl4, choices=1:3, display="sites", scaling="symmetric")
    spp <- as.data.frame(cbind(dune.env$SITE_ID,sp))
    with(dune.env, ordilabel(pl4,labels=spp$V1,col="black", fill=NA, border=NA))