[R-sig-eco] returning site and species coordinates in NMDS using vegan

Gavin Simpson gavin.simpson at ucl.ac.uk
Wed Sep 21 13:21:26 CEST 2011


On Tue, 2011-09-20 at 20:54 +0000, L Quinn wrote:
> Hi,
> I am running a simple NMDS as outlined by Jari Oksanen in vegantutor, e.g. 
> spp.dist<-vegdist(spp)spp.mds<-metaMDS(spp,trace=FALSE)spp.mds
> I am able to plot the results (species nicely overlaying sites) using 
> plot(spp.mds,display="species",type="t",family="sans",font=2,xlim=c(-0.4,0.4),ylim=c(-0.4,0.4))# and points(env.mds,display="sites")
> However, try as I might, I am not able to make this figure look pretty enough in R to satisfy journal editors/reviewers. I want to redraw the results in Excel, but I don't know how to extract species and site coordinates from spp.mds. I see that I can do this using isoMDS in MASS, but I'd prefer to use vegan. Perhaps I'm missing something obvious, but I haven't been able to find it anywhere so far. How does one go about extracting those coordinates?
> Thanks in advance.
> Lauren

In anticipation of you telling us what you want to do, the general
advice is to plot aspects of the model fit by hand, in stages.

# The recommended way of running NMDS (Minchin 1987)
##
data(dune)
# Global NMDS using monoMDS
sol <- metaMDS(dune)

## extract scrs
sites <- scores(sol, display = "sites")
spps  <- scores(sol, display = "species")

## compute axis ranges
xlim <- range(sites[,1], spps[,1])
ylim <- range(sites[,2], spps[,2])

## set up a blank plotting window
plot(sol, type = "n", xlim = xlim, ylim = ylim)

## now do plotting with base R plotting functions, e.g.
points(sites, col = "blue", pch = 16, cex = 1.2)
text(spps, labels = rownames(spps), col = "red", cex = 0.6)

If it is the overlap of labels etc that is annoying you,
ordipointlabel() is your friend, or you can fiddle with things by hand
using orditkplot(), push the result back to R and then plot it using
ordiplot().

## try this:
ordipointlabel(sol)

The success of any of these will depend on the number of sites and
species etc. and their spacing in the ordination. orditkplot() provides
the most flexibility, but you have to move all the labels by hand.

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-sig-ecology mailing list