MyNixOS website logo
Description

Make 'ggplot2' Versions of Vegan's Ordiplots.

The 'vegan' package includes several functions for adding features to ordination plots: ordiarrows(), ordiellipse(), ordihull(), ordispider() and ordisurf(). This package adds these same features to ordination plots made with 'ggplot2'. In addition, gg_ordibubble() sizes points relative to the value of an environmental variable.

ggordiplots

R-CMD-check [Github AllReleases])

The vegan package includes several functions for adding features to ordination plots: ordiarrows(), ordiellipse(), ordihull(), ordispider() and ordisurf(). This package adds these same features to ordination plots made with ggplot2. In addition, gg_ordibubble() sizes points relative to the value of an environmental variable.

The functions are written so that features from each can be combined in customized ordination plots.

The functions ord_labels() and scale_arrow() (used to ensure vector arrows fit within a plot) are exported to make it easier to generate custom ordination plots.

Installation

You can install the development version of ggordiplots from GitHub with:

# install.packages("devtools")
devtools::install_github("jfq3/ggordiplots")

You can install the latest release from CRAN with:

install.packages("ggordiplots")

Examples

Plot an ordination with ellipses around treatment group centroids (at distances of one standard deviation) with gg_ordiplot().

library(ggordiplots)
#> Loading required package: ggplot2
#> Loading required package: vegan
#> Loading required package: permute
#> Loading required package: lattice
#> This is vegan 2.6-4
#> Loading required package: glue
data("dune")
data("dune.env")
dune_bray <- vegdist(dune, method = "bray")
ord <- cmdscale(dune_bray, k = (nrow(dune) - 1), eig = TRUE, add = TRUE)
#> Warning in cmdscale(dune_bray, k = (nrow(dune) - 1), eig = TRUE, add = TRUE):
#> only 18 of the first 19 eigenvalues are > 0
plt1 <- gg_ordiplot(ord, groups = dune.env$Management, plot = FALSE)

plt1 is list with items named:

names(plt1)
#> [1] "df_ord"      "df_mean.ord" "df_ellipse"  "df_hull"     "df_spiders" 
#> [6] "plot"

The first 5 items are data frames for making plots. The last item is a ggplot:

plt1$plot

Fit a vector of Al concentrations to the ordination with gg_envfit().

Al <- as.data.frame(dune.env$A1)
colnames(Al) <- "Al"
plt2 <- gg_envfit(ord, env = Al, groups = dune.env$Management, plot = FALSE)
plt2$plot

Add ellipses from the first plot to the second plot. The resulting plot can be further customized using usual ggplot2 methods. For example, change the legend title.

plt2$plot +
  geom_path(data = plt1$df_ellipse, aes(x=x, y=y, color=Group)) +
  guides(color=guide_legend(title="Management")) # Change legend title
Metadata

Version

0.4.3

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows