2013-01-18 429 views
1

我們可以在R-igraph中隨節點大小改變文本大小嗎? 如果是,我們可以使用什麼屬性?任何示例?我們可以在R-igraph中改變文本大小以及節點大小嗎?

(通過文字我指的是節點名稱)

​​

比如我上面的網絡使用的igraph功能繪製如下:

plot.igraph(net,vertex.label=V(net)$name,layout=layout.fruchterman.reingold, 
      edge.color="black",edge.width=Eweight,edge.curved=F) 

如果我們看一下標籤對應於每個節點,每個具有相同的大小。我想根據其相應的節點大小來改變此標籤大小。例如大小(「w1」)>大小(「w5」)>大小(「w6」)等等。

+0

創建重複的例子,請通過包含一些示例代碼來展示你想要做的事情,擴展你的問題。 –

回答

4

您可以使用data.frame

library(igraph) 
dat <- data.frame(name=c("Alice", "Bob", "Cecil"),age=c(48,33,45)) 
g<-graph.data.frame(dat) 

然後改改一些屬性

V(g)$label.cex <- seq(0.5,5,length.out=6)   ## text size 
V(g)$size  <- seq(10,60,length.out=6)   ## circle size proportional to text size 

最後情節

plot(g, vertex.label = V(g)$name, 
    vertex.shape="circle", 
    vertex.color="red" 
) 

enter image description here

相關問題