2017-08-16 186 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