Draw Network in R (control edge thickness plus non-overlapping edges)

后端 未结 4 788
醉话见心
醉话见心 2021-01-30 15:27

I need to draw a network with 5 nodes and 20 directed edges (an edge connecting each 2 nodes) using R, but I need two features to exist:

  1. To be able to control the
4条回答
  •  再見小時候
    2021-01-30 15:47

    The package informatively named 'network' can draw directed networks fairly well, and handle your issues.

    ex.net <- rbind(c(0, 1, 1, 1), c(1, 0, 0, 1), c(0, 0, 0, 1), c(1, 0, 1, 0))
    
    plot(network(ex.net), usecurve = T, edge.curve = 0.00001,
         edge.lwd = c(4, rep(1, 7)))
    

    The edge.curve argument, if set very low and combined with usecurve=T, separates the edges, although there might be a more direct way of doing this, and edge.lwd can take a vector as its argument for different sizes.

    It's not always the prettiest result, I admit. But it's fairly easy to get decent looking network plots that can be customized in a number of different ways (see ?network.plot).

提交回复
热议问题