[R] Customizing ordination plots using symbols for factors

Sarah Berke skberke at gmail.com
Wed Apr 7 05:05:51 CEST 2010


Hi,

I could use a hand solving a fairly straightforward ordination plot problem:

I am conducing NMDS on some community data for roughly 300 localities
and 650 species.  I have a community matrix, a species attribute
matrix, and an environmental attributes matrix.  After running metaMDS
{vegan} on the community matrix, I can successfully use either of the
other two matrices to draw hulls around points belonging to various
classes of species attributes or environmental characteristics.  I can
also use either matrix to run envfit and plot vectors for different
variables.

But what I really want to do is just display the species ordination
and color code the points by levels of a particular factor from the
species attribute matrix.  For example, I've got 650 species that have
5 different feeding mechanisms, so I want each feeding mechanism to be
a different color (or different shape or whatever).

I was sure that this would be easy to figure out.  But I have been
scouring help files and R tutorials for 2 days, and I am at my wits
end!  If my points and my factors were in a single dataframe then I
would know how to do it, but I don't see how to make the matrix with
the factors talk to the ordination result (which is typeof=list).  I
assume that with() must be involved, but how?  I suspect that I've
actually read the relevant help files, but did not recognize the
answer as such.  All of the vegan documentation I've found seems to
assume that this is so basic that anyone could figure it out on their
own.


FWIW, here is an example of my code for plotting convex hulls around 3
different feeding groups, which works. comm.mds is the ordination of
the community matrix comm.mat, FD.mat is the species attributes
matrix.

comm.mds<- metaMDS(comm.mat, distance = "euclidean", k = 2, zerodist =
"add", noshare = 0)
plot(comm.mds, type="p", display="species")
     with(FD.mat, ordihull(comm.mds.t, feeding, show.groups = "1",
col = "yellow", lty = 1, lwd=3))
     with(FD.mat, ordihull(comm.mds.t, feeding, show.groups = "2",
col = "black", lty = 1, lwd=3)) t
     with(FD.mat, ordihull(comm.mds.t, feeding, show.groups = "3",
col = "green", lty = 1, lwd=3))

Any guidance would be greatly appreciated!

Many thanks,
Sarah



More information about the R-help mailing list