I am trying to use igraph (1.3.2) & ggraph (2.0.5) to visualize networks where the edge aesthetics are modulated by a numeric value. I would assume this is a pretty common thing, but I have been running into issues lately (likely due to an update? I'm on R 4.1.2) where ggraph cannot recognize edge attributes that take a numeric value.
Here is an example code:
library(ggraph)
library(igraph)
Nodes <- data.frame(Id = c(1,2), Label = c('a','b'))
Edges <- data.frame(to = c(2,1), from = c(1,2), val = c(0.2,0.5))
net <- graph_from_data_frame(d=Edges, vertices = Nodes, directed = T)
layout <- create_layout(net, layout = 'fr')
ggraph(layout) + geom_edge_fan(aes(color = val))
I get the error
Error in check.length(gparname) :
'gpar' element 'lwd' must not be length 0
If I change val
to strings or booleans, the issue goes away, but obviously this is not what I want to do.
I wasn't having this issue a few months ago, but recently I have been having this problem. Any advice on how to get around this would be much appreciated. Thanks!