I want to plot a directed graph, where each edge width and arrow width is proportional to edge weights. I also want to display the weight of the edge on the graph. I am able to produce this graph with code
library(ggraph)
mydf <- structure(list(from = c("NE", "NE", "NE", "NE", "NW", "NW", "NW",
"SE", "SW", "SW", "SW"), to = c("NE", "NW", "SE", "SW", "NE",
"NW", "SW", "SE", "NE", "NW", "SW"), weights = c(32L, 16L, 1L,
2L, 10L, 91L, 34L, 1L, 5L, 33L, 63L)), class = "data.frame", row.names = c(NA, -11L))
g <- graph_from_data_frame(mydf)
ggraph(g, layout = data.frame(x = c(1, 0, 1, 0), y = c(1, 1, 0, 0))) +
geom_edge_arc(arrow = arrow(type = "closed", length = unit(3, 'mm')),
aes(width = weights,
label = weights),
start_cap = circle(5, 'mm'),
end_cap = circle(5, 'mm'),
label_dodge = unit(2.5, 'mm'),
strength = 0.4,
alpha = 0.2) +
geom_node_point() +
geom_node_text(aes(label = name), repel=TRUE) +
coord_fixed()
My problem with this graph is that arrows are not clearly plotted. It looks like multiple arrows are drawn one over the other.
It might be that I am missing something on how to use arrows, and I am looking for some hints to plot them better and make the graph easier to interpret.