Search code examples
rplotvegan

Customising vegan ordination plot


I have a dataset including 100 species and therefore it's very bad to plot. So I want to pick out a subset of these species and plot them in a RDA plot. I have been following this guideline

The code looks like this:

## load vegan
require("vegan")

## load the Dune data
data(dune, dune.env)

## PCA of the Dune data
mod <- rda(dune, scale = TRUE)

## plot the PCA
plot(mod, scaling = 3)

## build the plot up via vegan methods
scl <- 3 ## scaling == 3
colvec <- c("red2", "green4", "mediumblue")
plot(mod, type = "n", scaling = scl)
with(dune.env, points(mod, display = "sites", col = colvec[Use],
                  scaling = scl, pch = 21, bg = colvec[Use]))
text(mod, display = "species", scaling = scl, cex = 0.8, col = "darkcyan")
with(dune.env, legend("topright", legend = levels(Use), bty = "n",
                  col = colvec, pch = 21, pt.bg = colvec))

This is the plot you end up with. Now i would really like to remove some of the species from the plot, but not the analysis. So the plot only shows like Salrep, Viclat, Aloge and Poatri.

Help is appreciated.


Solution

  • The functions you are doing the actual plotting with have an argument select (at least text.cca() and points.cca(). select takes either a logical vector of length i indicating whether the ith thing should be plotted, or the (numeric) indices of the things to plot. The example would then become:

    ## Load vegan
    library("vegan")
    
    ## load the Dune data
    data(dune, dune.env)
    
    ## PCA of the Dune data
    mod <- rda(dune, scale = TRUE)
    
    ## plot the PCA
    plot(mod, scaling = 3)
    
    ## build the plot up via vegan methods
    scl <- 3 ## scaling == 3
    colvec <- c("red2", "green4", "mediumblue")
    
    ## Show only these spp
    sppwant <- c("Salirepe", "Vicilath", "Alopgeni", "Poatriv")
    sel <- names(dune) %in% sppwant
    
    ## continue plotting
    plot(mod, type = "n", scaling = scl)
    with(dune.env, points(mod, display = "sites", col = colvec[Use],
                      scaling = scl, pch = 21, bg = colvec[Use]))
    text(mod, display = "species", scaling = scl, cex = 0.8, col = "darkcyan",
         select = sel)
    with(dune.env, legend("topright", legend = levels(Use), bty = "n",
                      col = colvec, pch = 21, pt.bg = colvec))
    

    Which gives you:

    enter image description here