【问题标题】:How can I make the following picture as a network in R (qgraph or igraph)?如何将以下图片制作为 R 中的网络(qgraph 或 igraph)?
【发布时间】:2017-11-18 11:22:34
【问题描述】:

我想在 R 中制作以下图片。我画了它,但我想根据它们的值加权边缘大小,使用这两种不同的颜色(红色和蓝色)和两种不同的边缘类型(虚线和没有虚线)。我该怎么做?

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

【问题讨论】:

  • 使用您用于构建图表的数据编辑您的问题。使用它在 SO 上发布问题:MVCE
  • 好的。现在我用数据集添加了 data.frame 函数

标签: r networking igraph r-qgraph


【解决方案1】:

我终于成功地制作了这张照片。我在 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"];
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-07
    • 2012-08-25
    • 1970-01-01
    • 1970-01-01
    • 2013-02-28
    • 2012-03-01
    • 2017-03-08
    • 2021-08-30
    相关资源
    最近更新 更多