2017-08-16 177 views
1

當我嘗試使用edge.color屬性設置邊緣的顏色時,它不起作用(我得到默認灰色)。但是,當我將相同的屬性放在plot命令中時,它可以工作!我做錯了什麼? (我正在使用R版本3.4.1(2017-06-30) - 在Linux盒子上的「單個蠟燭」)。其他屬性如arrow.size寬度對我來說工作正常,只是顏色不對!無法設置igraph邊緣的顏色

根據本Rpub教程的igraph,https://rpubs.com/kateto/netviz我應該能夠做到兩者兼得......

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") 

回答

3

使用color,不edge.color(因爲它是一個邊緣屬性,這已經是無歧義)。

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

enter image description here

+0

啊謝謝!所以Rpubs文檔是不正確的!他們在他們的例子中顯示E(淨)$ edge.color < - 「gray80」...非常感謝! –

+0

是的,它可能已經過時,不確定。他們似乎使用'V(淨)$顏色'。我只是嘗試了一些變化,因爲我知道它應該以這種或那種方式工作。 – Axeman

+1

@AdrianTompkins我在[github]上報告過它(https://github.com/kateto/R-Network-Visualization-Workshop/issues/2)。 – Axeman