File Exchange

image thumbnail

Plot Food Web

version (11.9 KB) by Francisco de Castro
Functions for ecological modelling

1 Download

Updated 06 Dec 2019

GitHub view license on GitHub

PLOTFOODWEB makes it easy to produce beautiful 3D or 2D figures of ecological food webs. The only required argument is the adjacency matrix of predator-prey connections. Sizes, colors, trophic levels, and the spatial arrangement can be specified as optional arguments. The submission figure shows three possibilities. In the top-left is the default type. The top-right is high-quality with random arrangement and the size of spheres as a function of the Log of body mass. At the bottom, a biplot where species are arranged according to mass (X-axis) and trophic level (Y-axis).

Cite As

Francisco de Castro (2020). Plot Food Web (, GitHub. Retrieved .

Comments and Ratings (4)

To Joel Sande:
I don't know what you mean. This is matlab, not C. There is no main(). How to use the function is explained typing "help plotfoodweb" at the matlab command prompt.

Joel Sande

I want to do something like that. But applied to neural network.

Please show in a main() how to use it.

Ronald: The data comes from the niche model (Williams & Martinez 2000), with S= 100 and C= 0.15 (if I remember correctly). I didn't save it after generating the figure.


Please provide the example data as shown in the picture of the submission.


Connect to Github

Corrected detail in the help.

new figure

Add a new type of plot. Reorganize help

Correct brewer colormap problem
Correct minor typos in help

Use default color map if Brewer color function is not installed.

Added required function 'calcarc'

Forgot to include the file in previous update

Change 'mds' option in 'arrange' for 'pca' (principal components analysis).
Added option to color by kmeans clustering of adjacency matrix.

Ability to specify variable line colors.
Possibility to use curved lines

Ability to provide a full interactions matrix, not just adjacency matrix of 0 and 1.

Rearranged and improved help

Added missing function fwrotation

Option to plot in 2D
Option to arrange species by multidimensional scaling
Faster plotting
Optional transparency of lines

Option to plot the food web in 2D.
Option to arrange species in 3D with mutidimensional scaling
Faster plotting of cylinders connecting species
Optional transparency of lines

MATLAB Release Compatibility
Created with R2008b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: Patchline