2017-11-18 293 views
0

我想在R中畫出下面的圖片。我繪製它,但是我想根據它們的值來加權邊緣大小,使用這兩種不同的顏色(紅色和藍色)以及兩種不同的邊緣類型(虛線而不是虛線)。我該怎麼做呢?如何將以下圖片製作爲R(qgraph或igraph)中的網絡?

network drawing

下面是數據幀

data.frame(Node = c("MF", "MF", "SF","SF", "AFS","AFS"), Edge.col= c(rep(c("Blue","Red"),3)), RC = c(215, 79, 38, 22, 659, 43), SER = c(285, 43, 120, 44, 252, 95)) 
+0

編輯您的問題與您用來建立圖形的數據。用這個在SO上發佈問題:[MVCE](https://stackoverflow.com/help/mcve) – skrubber

+0

好的。現在我添加了data.frame函數與數據集 –

回答

0

我終於設法使畫面的代碼。我無法在R中完成,但我使用了graphviz軟件。下面我顯示的代碼:

digraph g { 
layout = "neato" 

MF -> SER [color=blue, penwidth=3.24, label = "285"]; 
MF -> SER [color=red, penwidth=0.49, label = "43"]; 
MF -> RC [style=dashed, color=blue, penwidth=2.44, label = "215"]; 
MF -> RC [style=dashed, color=red, penwidth=0.9, label = "79"]; 
SF -> SER [color=blue, penwidth=1.36, label = "120"]; 
SF -> SER [color=red, penwidth=0.5, label = "44"]; 
SF -> RC [style=dashed, color=blue, penwidth=0.43, label = "38"]; 
SF -> RC [style=dashed, color=red, penwidth=0.25, label = "22"]; 
AFS -> SER [color=blue, penwidth=2.86, label = "252"]; 
AFS -> SER [color=red, penwidth=1.08, label = "95"]; 
AFS -> RC [style=dashed, color=blue, penwidth=7.5, label = "659"]; 
AFS -> RC [style=dashed, color=red, penwidth=0.49, label = "43"]; 

MF[pos="0,2!", height = 1, width = 1.5, fontsize = 28, fontname = "Helvetica"] 
SF [pos="-2,-2!", height = 1, width = 1.5, fontsize = 28, fontname = "Helvetica"] 
AFS [pos="2,-2!", height = 1, width = 1.5, fontsize = 28, fontname = "Helvetica"] 
RC [pos="1,0!", label = "BB",shape=Mdiamond, height = 1, width = 1.5, fontsize = 28, fontname = "Helvetica"]; 
SER [pos="-1,0!", label = "P-S", shape=Msquare, height = 1, width = 1, fontsize = 28, fontname = "Helvetica"]; 
}