Closed jlguilherme closed 10 months ago
I admit to some confusion to the edge order of drawing, but in your case the simple fix is to use the group aesthetic:
ggraph(Netw) +
geom_edge_link(aes(edge_colour = cat, width = strength,group=cat)) +
scale_edge_width_continuous(limits = c(0,1), range=c(.1,2.5)) +
scale_edge_colour_manual(values = c("moderate" = "grey80", "weak" = "red", "v_strong" = "#3E1404", "strong" = "#9F6B39"))
Fwiw I have found that only geom_edge_link2
respects the ordering of a factor variable. If the values of an edge are factors you can control the order in which the edges are drawn by setting the order of the factor levels, but again only for geom_edge_link2.
Hi - great package! Thanks!
I'm having an issue with the order edges are plotted with geom_edge_link() - I need them to respect the order of factor levels (factor cat below) and to have different widths according to value in strength.
I would expect edges to be plotted in "order" they appear in the edge list that feeds tbl_graph but that does not seem to be the case - what should be the expected behaviour?
Consider the following dataframe
Order the level in factor 'cat'
edge list
edge.list <- df
node list
tbl_graph file
Netw <- tbl_graph(nodes = node.list, edges = edge.list)
plot it!
I get this:
However, I would expect the red edges (i.e. level "weak") to be in the 'back' and over all the other edges.
I tried different things but just don't understand if this is the expected behaviour and how I can obtain my desired output.
Thanks for your help!