Search code examples
rbipartite

Stop plot edges being cut off in bipartite package (plotweb)


With the plotweb() function in the bipartite package in R, I've created a network, but some of the labels are too long for the plot area. As a result, they are being cut off at the top and bottom (I've included a picture).

I'm trying to make it fit in the plot, or if not possible, to be able to export it as an image without the edges being cut off.

I've tried par(mar=c(), but that doesn't seem to do anything. ybig() can allow the top half to fit in, but it doesn't change the bottom section.

See photo: labels being cut off from the web


Solution

  • It seems that the argument y.lim could be adjusted in such cases. From help(plotweb), about y.lim:

    [...] Useful if labels are plotted outside the plotting region and for multitrophic plots [...]

    Here is an example:

    library(bipartite)
    
    data(Safariland)
    # Forge some long names/labels
    cn <- colnames(Safariland)
    rn <- rownames(Safariland)
    colnames(Safariland) <- paste(cn, cn)
    rownames(Safariland) <- paste(rn, rn)
    
    # plotweb with trying to fit the labels - tweak y.lim until you get it right
    plotweb(Safariland, text.rot = 90, y.lim = c(-1.5, 4))
    

    enter image description here