/bipartite_webs

Edited visweb and plotweb functions from bipartite package

Primary LanguageR

Edits to functions visweb and plotweb from the R package bipartite

Note the naming equivalence:

  • plot_grid corresponds to bipartite::visweb (Aug 19, 2015)
  • plot_bipartite corresponds to bipartite::plotweb (Oct 6, 2014)

Original code for functions visweb (plot_grid) and plotweb (plot_bipartite) was taken from bipartite GitHub repository. I made a fork initially, but I realized soon than the repository is taking more space that I am willing to allocate.

All in all, I am only interested in editing the two functions mentioned above for personal use, so I started this separate repository.

Usage

This is work in progress!

library(bipartite)
# Source the functions from this repository
source("https://raw.githubusercontent.com/valentinitnelav/bipartite_webs/master/R/plot_bipartite.R")
source("https://raw.githubusercontent.com/valentinitnelav/bipartite_webs/master/R/plot_grid.R")

Edits / Additional features:

in plot_bipartite (bipartite::plotweb)

  • disable par modifications during function call;
  • label adjustments:
  • allow label size separately for lower and upper trophic levels;
  • allow text rotation separately for lower and upper labels;
  • allow adjustment of pos, offset and font separately for lower and upper labels;

in plot_grid (bipartite::visweb)

  • disable par modifications during function call;
  • add x.lim & y.lim arguments used for the same purpose as in plotweb;
  • label adjustments:
    • allow side, las, font and mgp changes for axis labels;
    • add mtext for axis titles;
    • better replace mtext with text, which allows text rotation with srt; see this FAQ or this blog post;
    • use also text for axis labels instead of the current axis (for the same reason as above);
    • re-arrange code (plot first matrix, then annotation) - this helps detecting if labels are under the matrix when testing edits;
    • allow different sorting of the matrix to get the nestedness visual effect in any desired corner. This can be helpful when needing to rotate/further edit graphs in Inkscape.
    • implement label/species coloring

License

The package bipartite is licensed under GPL (mentioned here) and this trickles down to this repository.