Arranging arrows between points nicely in ggplot2

后端 未结 2 777
轻奢々
轻奢々 2020-12-17 04:11

(note - this is the same piece of work as using multiple size scales in a ggplot, but I\'m asking a different question)

I\'m trying to construct a plot which shows

2条回答
  •  悲&欢浪女
    2020-12-17 04:38

    I thought since nobody has given a solution i would provide an example of package more aimed a this sort of problem:

    vecs  <- data.frame(vecs =1:6,size=sample(1:100,6))
    edges <- data.frame(from=sample(1:6,9,replace=TRUE), to=sample(1:6,9,replace=TRUE))
    
    library(igraph)
    
    g      <- graph.data.frame(edges, vertices = vecs, directed = TRUE)
    coords <- cbind(sample(1:20,6), sample(1:20,6))
    
    
    plot(g, vertex.size=V(g)$size,vertex.color="white",layout=coords,axes=TRUE)
    

    This will at least solve your arrows before the circle issue and also when there are reciprocal arrows it will adjusts them with the curved lines as in 2<->5:

    enter image description here

    (arrrow sizes, line widths, colours etc can of course be modified)

提交回复
热议问题