I posted last week a simple function to plot networks using ggplot2 package. Here is version 2. I still need to work on figuring out efficient vertex placement.
Changes in version 2:
You have one of three options: use an igraph object, a matrix, or a dataframe (matrices will be converted to data frames within the function)
If you have data on food webs similar to that provided in the Takapoto dataset provided in the NetIndices package, you can set trophic = “TRUE”, and gggraph will use the function TrophInd to assign trophic levels (the y axis value) to each vertex/node. You have to provide additional information along with this option such as what the imports and exports are, see NetIndices documentation.
I added some simple error checking.
if using method=”df” and trophic=”FALSE”, x axis placement of vertices is now done using the function degreex (see inside the fxn), which sorts vertices according to their degree (so the least connected species are on the left of the graph; note that species with the same degree are not stacked on the y-axis because e.g., two vertices of degree=5 would get x=3 then x=4).