Adrian Tompkins Adrian Tompkins - 1 year ago 56
R Question

Can't set colors of edges in igraph network

When I try to set the color of edges using the edge.color attribute, it doesn't work (I get default grey). However when I put the same attribute in the plot command, it works! What I am doing wrong? (I am using R version 3.4.1 (2017-06-30) -- "Single Candle" on a linux box). Other attributes such as arrow.size and width work fine for me, it is just the color that doesn't!

According to this Rpub tutorial for igraph, https://rpubs.com/kateto/netviz I should be able to do it both ways...

require(igraph)
data<-matrix(rexp(25, rate=.1), ncol=5)
gr<-graph.adjacency(data,mode="directed",weighted=T,diag=T)

# this gives gray default edges, WHY?
E(gr)$edge.color<-"blue"
plot(gr)

# this give blues edges:
plot(gr,edge.color="blue")

Answer Source

Use color, not edge.color (since it is an edge attribute this is already non-ambiguous).

E(gr)$color<-"blue"
plot(gr)

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download