[R-sig-eco] ordiplot questions

Chris Habeck habeck.cw at gmail.com
Thu Jul 21 16:30:21 CEST 2011


Hi Gavin,

Thank you for your valuable help and suggestions.  The problem with the tick
intervals is now sorted out with the code you provided.  Thanks!

Also, the code you provided for plotting vector arrows without the labels is
much appreciated, but I have run into one hiccup in this regard:  the arrow
lengths are uniform, rather than being scaled by the correlation.  Can this
problem be overcome?  This time, I have provided the data and code
as attachments   Hopefully, they pass the posting filter!

Best,

Chris
****************************************
Chris Habeck
Remnant Expansion Project
Postdoctoral Research Associate
Department of Biology
Washington University at St. Louis



On Thu, Jul 21, 2011 at 5:01 AM, Gavin Simpson <gavin.simpson at ucl.ac.uk>wrote:

> On Wed, 2011-07-20 at 20:54 -0400, Chris Habeck wrote:
> > Hi,
> >
> > I have two questions regarding the use of ordiplot{vegan} and
> envfit{vegan}.
> >  Hopefully someone can help.
>
> Your 1st question isn't very clear, perhaps because the example you give
> is not reproducible and the figure you attached hasn't made it through
> the mailing list filters.
>
> > First question:  I am trying to maximize the space used to project my
> sites
> > onto a graph of NMDS results by defining the xlim and ylim, but the axes
> > default to separate tick intervals (see attached figure).  How do I get
> the
> > intervals to behave?
>
> What do you mean by "behave"? ylim and xlim do not set the tick
> intervals, they just set the limits of the plotting region (well almost,
> R adds a small fudge amount of 4% IIRC and then finds pretty tick
> locations within the range) in data coordinates. If you mean that the
> tick interval on both axes is different, as in:
>
> ## from ?metaMDS
> data(dune)
> library(MASS) ## isoMDS
> sol <- metaMDS(dune)
> ordiplot(sol, type="t", display = "sites", ylim = c(-0.7,0.7),
>         xlim = c(-0.7,0.7))
>
> then you need make the plotting region square - the axes are in the same
> unit scale so it is the relative length of the axes on the display that
> is determining the placement of ticks.
>
> Alternatively suppress the axes and draw the axes with ticks where you
> want them:
>
> ordiplot(sol, type="t", display = "sites", ylim = c(-0.7,0.7),
>         xlim = c(-0.7,0.7), xaxt = "n", yaxt = "n", bty = "n")
> locs <- zapsmall(seq(-0.7, 0.7, by = 0.1))
> axis(side = 1, at = locs)
> axis(side = 2, at = locs)
> box()
>
> Automated plotting makes a number of assumptions about what the user
> wants. If those aren't what is really desired then one must get ones
> hands dirty and build the plot up themselves using standard R plotting
> functions.
>
> > Second question:  I would like to display the vector lines from my envfit
> > object, but not the variable labels.  Is this possible?
>
> Yes, same advice as above, draw them yourself:
>
> ## continuing from above
> data(dune.env)
> vf <- envfit(sol ~ A1, data = dune.env)
>
> The end-points of the arrows are stored in $vectors$arrows of the
> returned object, so we can use the standard R function `arrows()` to
> plot them:
>
> ends <- vf$vectors$arrows
> ends <- ends * ordiArrowMul(ends, c(0,0))
> arrows(0, 0, ends[1], ends[2], length = 0.1, col = "blue")
>
> I use the helper function ordiArrowMul() to work out the correct
> multiplier to scale the unit length arrow appropriately for the plot.
>
> > Below is the associated code used to produce the attached figure.
> >
> > library(vegan)
> > rem.mds = metaMDS(rem.spp)
> > rem.ef <- envfit(rem.mds,
> > rem.env[,c(2,3,4,5,7,8,10:12,15:18,20,21,22,24,28)],na.rm = TRUE, permu =
> > 999)
> > rem.ef
>
> Not reproducible as we don't have your data. Try to supply a proper
> reproducible example in the future by giving us your data, or, *better*
> do as I did and take one of the provided example data sets and base your
> example on that.
>
> HTH
>
> G
>
> >
> > rem.plot = ordiplot(rem.mds, type = "none", display = "sites", xlim =
> > c(-0.7,0.7), ylim = c(-0.7,0.7))
> > points(rem.plot, "sites", pch=21, cex = 2, col="black", bg="white")
> > plot(rem.ef, p.max = 0.05, col = "red", cex = 1.2)
> >
> >
> >
> > ****************************************
> > Chris Habeck
> > Remnant Expansion Project
> > Postdoctoral Research Associate
> > Department of Biology
> > Washington University at St. Louis
> > _______________________________________________
> > R-sig-ecology mailing list
> > R-sig-ecology at r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
> --
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  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