graphviz / DiagrammeR - 从上到下,然后从左到右的子图

graphviz / DiagrammeR - subgraphs top to bottom, then left to right

我正在尝试重新创建一个图表,其中我有 5 个不同的子图,或者 "clusters." 我想要两个 "columns" 子图,第一列有三个子图,第二列有第二个.这是我到目前为止编写的代码,但输出不是我想要的:

grViz("
      digraph G {
      rankdir = LR
      edge[style = invis]
      node[fontname = 'helvetica', width = 1.5, height = 0.5, fontsize = 20]
      graph[fontname = 'helvetica', fontsize = 20]

      subgraph cluster_one {

      node[shape = box, style = filled, fillcolor = lightblue];
      label = '30 days post-procedure';
      style = dashed;
      fontname = 'helvetica-bold';
      rank = same;

      node[shape = box, style = filled, color = black];
      tab6 [label = 'FU within window (n=@@1-1)']
      tab7 [label = 'FU outside window (n=@@1-2)']
      tab8 [label = 'Missed visit (n=@@1-3)']
      tab9 [label = 'Exit study prior to visit (n=@@1-4)']
      tab10 [label = 'Visit pending (n=@@1-5)']
      tab11 [label = 'Unknown (n=@@1-6)']

      tab6 -> tab8
      tab7 -> tab11

      }

      subgraph cluster_two {

      node[shape = box, style = filled, fillcolor = lightblue];
      label = '1 year post-procedure';
      style = dashed;
      fontname = 'helvetica-bold';
      rank = same;

      node[shape = box, style = filled, color = black];
      tab12 [label = 'FU within window (n=@@2-1)']
      tab13 [label = 'FU outside window (n=@@2-2)']
      tab14 [label = 'Missed visit (n=@@2-3)']
      tab15 [label = 'Exit study prior to visit (n=@@2-4)']
      tab16 [label = 'Visit pending (n=@@2-5)']
      tab17 [label = 'Unknown (n=@@2-6)']

      tab12 -> tab14
      tab13 -> tab17

      }

      subgraph cluster_three {

      node[shape = box, style = filled, fillcolor = lightblue];
      label = '2 years post-procedure';
      style = dashed;
      fontname = 'helvetica-bold';
      rank = same;

      node[shape = box, style = filled, color = black];
      tab18 [label = 'FU within window (n=@@3-1)']
      tab19 [label = 'FU outside window (n=@@3-2)']
      tab20 [label = 'Missed visit (n=@@3-3)']
      tab21 [label = 'Exit study prior to visit (n=@@3-4)']
      tab22 [label = 'Visit pending (n=@@3-5)']
      tab23 [label = 'Unknown (n=@@3-6)']

      tab18 -> tab20
      tab19 -> tab23

      }

      subgraph cluster_four {

      node[shape = box, style = filled, fillcolor = lightblue];
      label = '1 year post-randomization';
      style = dashed;
      fontname = 'helvetica-bold';
      rank = same;

      node[shape = box, style = filled, color = black];
      tab24 [label = 'FU within window (n=@@4-1)']
      tab25 [label = 'FU outside window (n=@@4-2)']
      tab26 [label = 'Missed visit (n=@@4-3)']
      tab27 [label = 'Exit study prior to visit (n=@@4-4)']
      tab28 [label = 'Visit pending (n=@@4-5)']
      tab29 [label = 'Unknown (n=@@4-6)']

      tab24 -> tab26
      tab25 -> tab29

      }

      subgraph cluster_five {

      node[shape = box, style = filled, fillcolor = lightblue];
      label = '2 years post-randomization';
      style = dashed;
      fontname = 'helvetica-bold';
      rank = same;

      node[shape = box, style = filled, color = black];
      tab30 [label = 'FU within window (n=@@5-1)']
      tab31 [label = 'FU outside window (n=@@5-2)']
      tab32 [label = 'Missed visit (n=@@5-3)']
      tab33 [label = 'Exit study prior to visit (n=@@5-4)']
      tab34 [label = 'Visit pending (n=@@5-5)']
      tab35 [label = 'Unknown (n=@@5-6)']

      tab30 -> tab32
      tab31 -> tab35

      }

      tab8 -> tab12 -> tab14 -> tab18 -> tab20;
      tab8 -> tab26 -> tab30 -> tab32;

      }

      [1]: c(1, 2, 3, 4, 5, 6)
      [2]: c(1, 2, 3, 4, 5, 6)
      [3]: c(1, 2, 3, 4, 5, 6)
      [4]: c(1, 2, 3, 4, 5, 6)
      [5]: c(1, 2, 3, 4, 5, 6)
      ")

输出:

基本上,我希望“30 天 post-程序”、“1 年 post-程序”和“2 年 post-程序”的子图是在左侧(或第一个 "column"),顶部为 30 天,中间为 1 年,底部为 2 年。在右侧(或第二个 "column"),我希望 1 年 post-随机化位于顶部,2 年位于底部。这是我正在谈论的内容的粗略草图:

如有任何想法或建议,我们将不胜感激。谢谢!

将 5 个簇嵌入 2 个簇中并添加一条不可见边:

digraph G {
      rankdir = LR
      edge[style = invis]
      node[fontname = "helvetica", width = 1.5, height = 0.5, fontsize = 20]
      graph[fontname = "helvetica", fontsize = 20]

  subgraph clusterLeft{
      peripheries=0

      subgraph cluster_one {
      peripheries=1

      node[shape = box, style = filled, fillcolor = lightblue];
      label = "30 days post-procedure";
      style = dashed;
      fontname = "helvetica-bold";
      rank = same;

      node[shape = box, style = filled, color = black];
      tab6 [label = "FU within window (n=@@1-1)"]
      tab7 [label = "FU outside window (n=@@1-2)"]
      tab8 [label = "Missed visit (n=@@1-3)"]
      tab9 [label = "Exit study prior to visit (n=@@1-4)"]
      tab10 [label = "Visit pending (n=@@1-5)"]
      tab11 [label = "Unknown (n=@@1-6)"]

      tab6 -> tab8
      tab7 -> tab11

      }

      subgraph cluster_two {
      peripheries=1

      node[shape = box, style = filled, fillcolor = lightblue];
      label = "1 year post-procedure";
      style = dashed;
      fontname = "helvetica-bold";
      rank = same;

      node[shape = box, style = filled, color = black];
      tab12 [label = "FU within window (n=@@2-1)"]
      tab13 [label = "FU outside window (n=@@2-2)"]
      tab14 [label = "Missed visit (n=@@2-3)"]
      tab15 [label = "Exit study prior to visit (n=@@2-4)"]
      tab16 [label = "Visit pending (n=@@2-5)"]
      tab17 [label = "Unknown (n=@@2-6)"]

      tab12 -> tab14
      tab13 -> tab17

      }

      subgraph cluster_three {
      peripheries=1

      node[shape = box, style = filled, fillcolor = lightblue];
      label = "2 years post-procedure";
      style = dashed;
      fontname = "helvetica-bold";
      rank = same;

      node[shape = box, style = filled, color = black];
      tab18 [label = "FU within window (n=@@3-1)"]
      tab19 [label = "FU outside window (n=@@3-2)"]
      tab20 [label = "Missed visit (n=@@3-3)"]
      tab21 [label = "Exit study prior to visit (n=@@3-4)"]
      tab22 [label = "Visit pending (n=@@3-5)"]
      tab23 [label = "Unknown (n=@@3-6)"]

      tab18 -> tab20
      tab19 -> tab23

      }
  }
  subgraph clusterRight {
      peripheries=0

      subgraph cluster_four {
      peripheries=1

      node[shape = box, style = filled, fillcolor = lightblue];
      label = "1 year post-randomization";
      style = dashed;
      fontname = "helvetica-bold";
      rank = same;

      node[shape = box, style = filled, color = black];
      tab24 [label = "FU within window (n=@@4-1)"]
      tab25 [label = "FU outside window (n=@@4-2)"]
      tab26 [label = "Missed visit (n=@@4-3)"]
      tab27 [label = "Exit study prior to visit (n=@@4-4)"]
      tab28 [label = "Visit pending (n=@@4-5)"]
      tab29 [label = "Unknown (n=@@4-6)"]

      tab24 -> tab26
      tab25 -> tab29

      }

      subgraph cluster_five {
      peripheries=1

      node[shape = box, style = filled, fillcolor = lightblue];
      label = "2 years post-randomization";
      style = dashed;
      fontname = "helvetica-bold";
      rank = same;

      node[shape = box, style = filled, color = black];
      tab30 [label = "FU within window (n=@@5-1)"]
      tab31 [label = "FU outside window (n=@@5-2)"]
      tab32 [label = "Missed visit (n=@@5-3)"]
      tab33 [label = "Exit study prior to visit (n=@@5-4)"]
      tab34 [label = "Visit pending (n=@@5-5)"]
      tab35 [label = "Unknown (n=@@5-6)"]

      tab30 -> tab32
      tab31 -> tab35

      }
  }

  tab17 ->  tab28
}