简体   繁体   English

如何将以下图片作为R(qgraph或igraph)中的网络?

[英]How can I make the following picture as a network in R (qgraph or igraph)?

I would like to make the following picture in R. I draw it but i would like to weight the edge size according to their value, use this two different colors (red and blue), and two different edge types (dashed and not dashed). 我想在R中制作以下图片。我将其绘制出来,但我想根据其值加权边缘大小,使用这两种不同的颜色(红色和蓝色),以及两种不同的边缘类型(虚线和非虚线) 。 How do I do this? 我该怎么做呢?

network drawing 网络图

Here is the code for the dataframe 这是数据框的代码

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

I finally managed to make the picture. 我终于设法拍下了照片。 I couldn't do in R, but I used the software graphviz. 我在R中无法做到,但是我使用了graphviz软件。 Below I show the code: 下面我显示代码:

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"];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM