Thank you for your code below. It has been very helpful.

Laura

On Tue, Sep 14, 2010 at 8:51 AM, Gavin Simpson <gavin.simpson@ucl.ac.uk>wrote:

> On Tue, 2010-09-14 at 08:08 -0700, Laura S wrote:
> > Dear Gavin and Jari:
> >
> > Thank you both for your responses. I greatly appreciate it.
>
> Thanks Laura,
>
> One way to do this would be
>
> set.seed(123)
> ## generate a gradient
> grad <- seq(0, 6, length = 20)
> ## and optima
> opt <- runif(20, min = min(grad), max = max(grad))
> ## and some rel. abundances
> abun <- rbeta(20, 1, 2)
>
> ## plot it
> plot(abun ~ grad, type = "n", ylim = range(c(0, abun)))
> points(abun ~ opt, type = "h")
> points(abun ~ opt, type = "p", pch = 21, col = "black", bg = "white")
>
> In the above I use pch 21 so I can fill the points with "white" to
> obscure the histogram bars 'type = "h"'.
>
> ## and if we have two groups say, A and B,
> ## like Vallend 2008, then we'd do
> ## grouping variable
> grp <- gl(2,10, labels = LETTERS[1:2])
> plot(abun ~ grad, type = "n", ylim = range(c(0, abun)))
> points(abun ~ opt, type = "h")
> points(abun ~ opt, type = "p", pch = 21, col = "black",
>       bg = c("white","black")[grp])
> legend("topleft", legend = c("A","B"), pt.bg = c("white","black"),
>       pch = 21, col = "black", bty = "n")
>
> If you want to add a baseline, then insert a call to abline()
> immediately *after* the plot call, e.g.:
>
> plot(abun ~ grad, type = "n", ylim = range(c(0, abun)))
> ## add baseline
> abline(h = 0, col = "grey")
> points(abun ~ opt, type = "h")
> points(abun ~ opt, type = "p", pch = 21, col = "black",
>       bg = c("white","black")[grp])
> legend("topleft", legend = c("A","B"), pt.bg = c("white","black"),
>       pch = 21, col = "black", bty = "n")
> ## box() call required as abline will over write the initial box
> ## slightly
> box()
>
> <snip />
>
> > b) Gravel et al. 2006. Ecology Letters, 9: 399-409.
> >
> > Figure 4 (left panel: a through d). This shows species relative
> > abundance (positioned along x-axis by rank according to niche optima)
> > versus niche position along the environmental gradient. I was trying
> > to describe this figure earlier.
>
> I don't like this version - why are the points joined as if a series
> along the gradient?
>
> HTH
>
> G
>
> > Thank you again for your time and consideration,
> > Laura
> >
> >
> >
> > On Tue, Sep 14, 2010 at 1:40 AM, Jari Oksanen <jari.oksanen@oulu.fi>
> > wrote:
> >         On 12/09/10 05:24 AM, "Laura S" <leslaura@gmail.com> wrote:
> >
> >         > Dear all:
> >         >
> >         > I am interested in plotting species relative abundance
> >         versus niche position
> >         > along an environmental gradient. I would like the species'
> >         position along
> >         > the the x-axis (environment gradient position) to be ranked
> >         according to
> >         > each species' niche optima. I have seen this type of plot in
> >         publications,
> >         > but I am not sure how to make a nice plot in R.
> >         >
> >
> >         Laura,
> >
> >         Just like Gav, I don't know what you want to achieve. However,
> >         package gravy
> >         (that was intended to put some meat in vegan) contains
> >         functions
> >         boxgradient() and gaussgradient(), and there is a slim change
> >         this is what
> >         you wanted to have. The gravy package is experimental, and not
> >         yet released,
> >         but it is available from http://vegan.r-forge.r-project.org/.
> >         You can
> >         automatically install the package on the command line
> >         (provided you have
> >         privileges to install packages) using
> >
> >         install.packages("gravy",
> >         repos="http://r-forge.r-project.org")
> >
> >         or selecting the repository address in the GUI installer.
> >
> >         The package is unreleased and experimental, and there may be
> >         rough edges.
> >         Proceed with care.
> >
> >         Cheers, Jari Oksanen
> >
> >
> >
> >
> > --
> > " Genius is the summed production of the many with the names of the
> > few attached for easy recall, unfairly so to other scientists"
> >
> > - E. O. Wilson (The Diversity of Life)
>
> --
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  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/<http://www.ucl.ac.uk/%7Eucfagls/>
>  UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>
>


-- 
" Genius is the summed production of the many with the names of the few
attached for easy recall, unfairly so to other scientists"

- E. O. Wilson (The Diversity of Life)

	[[alternative HTML version deleted]]

