I am trying to draw a network visualization to resemble a flow diagram. I'm fairly close with the following code, but I have a couple questions:
- Is this the best layout() algorithm, or can I manually assign a position for each node>
- How can I make sure that these nodes don't overlap in the plot (as they do here)?
- Can I assign one node as an "anchor" or starting point? i.e., can I make "C" the top-most or left-most node?
Thanks so much!!
library("igraph")
L3 <- LETTERS[1:8]
d <- data.frame(start = sample(L3, 16, replace = T), end = sample(L3, 16, replace = T),
weight = c(20,40,20,30,50,60,20,30,20,40,20,30,50,60,20,30))
g <- graph.data.frame(d, directed = T)
V(g)$name
E(g)$weight
ideg <- degree(g, mode = "in", loops = F)
col=rainbow(12) # For edge colors
plot.igraph(g,
vertex.label = V(g)$name, vertex.label.color = "gray20",
vertex.size = ideg*25 + 40, vertex.size2 = 30,
vertex.color = "gray90", vertex.frame.color = "gray20",
vertex.shape = "rectangle",
edge.arrow.size=0.5, edge.color=col, edge.width = E(g)$weight / 10,
edge.curved = T,
layout = layout.reingold.tilford)
See Question&Answers more detail:os