[R] vegan NMDS labels

David L Carlson dcarlson at tamu.edu
Fri Dec 9 20:29:15 CET 2016

You did not provide a reproducible example, but you should be able to get what you want as follows:


lbls <-as.integer(dune.env$Management)
grps <- levels(dune.env$Management)
ngrps <- length(grps)

example_dune <- metaMDS(dune, distance="bray", k=2)
ordiplot(example_dune, display="species", type="n")
points(example_dune, col="black", pch = lbls)
ordihull(example_dune, dune.env$Management, scaling = "symmetric", lty=lbls)
# Optionally add a legend
legend("topright", grps, pch=1:ngrps, lty=1:ngrps)

# However if you want to position the labels, try this
grp.lbls <- locator()
# Click where you want each label to appear.
# The pch symbols are circle, triangle, plus, X
# click where you want the label to appear for each group
# in that order and then click stop (upper left corner)
# of the window.
text(grp.lbls, grps)

Or just eyeball the coordinates. Once you have them where you want them, save them with dput() and include them in your script file (assuming you are planning to plot to a print device later).

David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Sibylle Stöckli
Sent: Friday, December 9, 2016 12:20 PM
To: r-help at r-project.org
Subject: [R] vegan NMDS labels

Dear R users

Does anybody know how it may be possible to plot the labels of a ordihull function separately (in R vegan)? We have studied the bee community in 5 different habitat types. As you see from the code, we use different point types (pch) and line types (lty). This is only possible if we change the habitat from character to integer. However, we prefer to show the labels as characters and not as integers 1-5? Furthermore, does anybody now how to plot the labels at the border and not in the centroid of the polygon (due to overlapping polygons it is not easy to assign them to the right polygon)?

Many thanks

### NMDS code ####
example_NMDS=metaMDS(community_matrix, # Our community-by-species matrix
                     distance = "bray", k=2) # The number of reduced dimensions
ordiplot (example_NMDS, display = 'species', type = 'n', xlim=c(-0.5,0.5), ylim=c(-0.7,0.7))
HabTyp<-as.integer(S1$H_Aggregat1) # 5 different habitats. 
points (example_NMDS, col="black", pch = HabTyp)
for (i in unique (HabTyp)) ordihull (example_NMDS, groups = HabTyp, show.group = i, draw = 'polygon', label=T, cex=1.5, lty=i)

	[[alternative HTML version deleted]]

R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DuneExample.png
Type: image/png
Size: 8863 bytes
Desc: DuneExample.png
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20161209/b1bb1382/attachment.png>

More information about the R-help mailing list