[R] envfit vector labels with ordiplot3d

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Sep 13 21:42:22 CEST 2011


On Tue, 2011-09-13 at 05:18 -0700, Briony wrote:
> It *really* does help to read the documentation for functions. Like most
> of the functions in vegan that extract information from ordinations,
> ordilabel() extracts information for "axes" 1 and 2 only, by default.

It also helps if I read the docs too!

The reason this was in 2d and will always be in 2d is that that is how
scatterplot3d works - the arrow head in 2d on the device has been placed
at the 2d translation of the original 3d coordinates.

It might help to push the label away from the arrow head a little bit:

ordilabel(pl$arrows * 1.075)

will push the label 7.5% away from the arrow head.

It seems that that is the best we can currently do with vegan.

When you say that this is not what you wanted, what did you want to
achieve?

G

> Does
> 
> ordilabel(pl$arrows, choices = 1:3)
> 
> work for you?
> 
> G
> 
> Thanks for the suggestion. Unfortunately that didn't work - it returned an
> error (Error in scores.default(x, choices = choices, display = display, ...)
> : subscript out of bounds). The ordilabel help says "ordilabel(x, display,
> labels, choices = c(1, 2)..." which seems to suggest the function might not
> allow a third axis at the moment?
> Cheers,
> Briony
> 
> 
> On Tue, Sep 13, 2011 at 2:53 AM, Gavin Simpson [via R] <
> ml-node+s789695n3807984h37 at n4.nabble.com> wrote:
> 
> > On Mon, 2011-09-12 at 03:24 -0700, Briony wrote:
> > > Thank you very much for the suggestion. And while I'm here, thank you for
> >
> > > vegan and the documentation that goes with it.
> > >
> > > >Function ordiplot3d uses scatterplot3d, and it returns also all
> > > >scatterplot3d items, like functions xyz.converter and points3d that
> > > >can be used for tuning labels.
> > >
> > > I tried ordilabel(pl$arrows) but the labels only seem to be in two
> > > dimensions.
> >
> > It *really* does help to read the documentation for functions. Like most
> > of the functions in vegan that extract information from ordinations,
> > ordilabel() extracts information for "axes" 1 and 2 only, by default.
> >
> > Does
> >
> > ordilabel(pl$arrows, choices = 1:3)
> >
> > work for you?
> >
> > G
> >
> > > >With ordixyplot I can see no other choice than that you edit the
> > > >function and preferably contribute your edited function to vegan
> > > >(and will be credited with the function help).
> > >
> > > I'm not a skilled enough user of R to edit the ordixyplot function - so
> > I'll
> > > pass on that invitation to anyone else who reads this thread?
> > >
> > > Thanks again,
> > > Briony
> > >
> > > Briony <brionynorton <at> gmail.com> writes:
> > >
> > > >
> > > > Hi R experts,
> > > >
> > > > I'm looking for some help with plotting vectors from envfit in vegan,
> > onto
> > > > a
> > > > 3d plot using ordiplot3d. So far I have
> > > >
> > > > data.mds <- metaMDS(data, k=3,trace = FALSE)
> > > > vect_data<-envfit(data.mds,vegdata[,3:21],choices=1:3,permu=9999)
> > > > ordiplot3d(data.mds,envfit=vect_data)
> > > > ordixyplot(data.mds,pch=pts,envfit=vect_data)
> > > >
> > > > (my data's not really called data, I thought it might be easier to
> > > > communicate this way)
> > > >
> > > > These display the vectors as arrows, but what I would really like is
> > for
> > > > the
> > > > arrows to be labelled, like what comes up automatically in ordirgl or
> > with
> > > > a
> > > > 2D ordiplot.
> > > >
> > > > I've gone through the help and tried everything I can work out, but I
> > must
> > > > be missing something important, because nothing's worked so far. I
> > would
> > > > be
> > > > happy to use ordixyplot and show a series of 2D plots, but I can't get
> > > > labels on those arrows either.
> > > >
> > > > Any pointers in the right direction would be gratefully received.
> > > > Briony
> > >
> > > Briony,
> > >
> > > There really is no way to do this automatically, but if someone fixes the
> >
> > > functions, we are happy to incorporate those changes in vegan.
> > >
> > > You may be able to achieve something like that with ordiplot3d, but I am
> > > not sure it looks completely satisfactory. Function ordiplot3d returns
> > > invisibly the plotting object which contains, among other items. the
> > > coordinates of arrow heads in the  flattened graph. So this could work:
> > >
> > > pl <- ordiplot3d(data.mds,envfit=vect_data)
> > > ordilabel(pl$arrows)
> > >
> > > Function ordiplot3d uses scatterplot3d, and it returns also all
> > > scatterplot3d items, like functions xyz.converter and points3d that
> > > can be used for tuning labels.
> > >
> > > With ordixyplot I can see no other choice than that you edit the
> > > function and preferably contribute your edited function to vegan
> > > (and will be credited with the function help).
> > >
> > > Cheers, Jari Oksanen
> > >
> > > ______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> > > --
> > > View this message in context:
> > http://r.789695.n4.nabble.com/envfit-vector-labels-with-ordiplot3d-tp3800669p3807015.html
> > > Sent from the R help mailing list archive at Nabble.com.
> > >
> > > ______________________________________________
> > > [hidden email] <http://user/SendEmail.jtp?type=node&node=3807984&i=0>mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> > --
> > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> >  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
> > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> >
> > ______________________________________________
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=3807984&i=1>mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> > ------------------------------
> >  If you reply to this email, your message will be added to the discussion
> > below:
> >
> > http://r.789695.n4.nabble.com/envfit-vector-labels-with-ordiplot3d-tp3800669p3807984.html
> >  To unsubscribe from envfit vector labels with ordiplot3d, click here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3800669&code=YnJpb255bm9ydG9uQGdtYWlsLmNvbXwzODAwNjY5fC0xODk1MTY2Mjk2>.
> >
> >
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/envfit-vector-labels-with-ordiplot3d-tp3800669p3809900.html
> Sent from the R help mailing list archive at Nabble.com.
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 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-help mailing list