graphviz / DiagrammeR - подграфы сверху вниз, затем слева направо - PullRequest
0 голосов
/ 27 апреля 2020

Я пытаюсь воссоздать диаграмму, где у меня есть 5 разных подграфов или «кластеров». Я хочу иметь два «столбца» подграфов, причем первый столбец содержит три подграфа, а второй - второй. Это код, который я написал до сих пор, но вывод не то, что я хочу:

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

Вывод: enter image description here

По сути, я хотите, чтобы подграфы для «30 дней после процедуры», «1 года после процедуры» и «2 года после процедуры» были слева (или в первой «колонке»), а 30 дней - вверху 1 год в середине и 2 года внизу. С правой стороны (или второй «колонки») я хочу, чтобы 1 год после рандомизации был наверху, а 2 года - на нижнем. Это грубый набросок того, о чем я говорю:

enter image description here

Любые идеи или предложения будут высоко оценены. Спасибо!

1 Ответ

2 голосов
/ 27 апреля 2020

встроить 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
}

enter image description here

...