1

How do I reproduce the figure:

enter image description here

Using graphviz nodes?

I have tested several combinations of rankings, without success. Here is a working example, which is still pretty far from the objective:

    digraph cohort_flow_chart {
    

  node [fontname = Helvetica, fontsize = 12, shape = box, style = rounded, width = 4]
  a[label = '1,618,937 \n hospitalisations due to alcohol\n and substence use related disorders']
  d[label = '1,882,629 \n hospitalisations due to\n schizophrenia']
  f[label = '780,811\n hospitalisations due to\n mood disorders']

  c[label = '114 million \n Brazilian cohort']

  b[label = '2,250,454 \n hospitalisations due to\n diabetes mellitus']
  e[label = '19,646,098\n hospitalisations due to\n cardiovascular diseases']
  g[label = '278,540\n hospitalisations due to\n tuberculossis']
  
  {rank = same a, b}
  {rank = same c, d, e}
  {rank = same f, g}

}

enter image description here

lf_araujo
  • 1,991
  • 2
  • 16
  • 39

1 Answers1

2

You needed edges or rank=source & rank=sink to get your nodes onto different ranks.
This adds clusters to get dot to treat each column separately:

digraph cohort_flow_chart {

 node [fontname = Helvetica, fontsize = 12, shape = box, style = rounded, width = 4]
 edge[style=invis]
 
  a[label = "1,618,937 \n hospitalisations due to alcohol\n and substence use related disorders"]
  d[label = "1,882,629 \n hospitalisations due to\n schizophrenia"]
  f[label = "780,811\n hospitalisations due to\n mood disorders"]

  c[label = "\n\n\n\n\n114 million \n Brazilian cohort\n\n\n\n\n\n" width=1.3]

  b[label = "2,250,454 \n hospitalisations due to\n diabetes mellitus"]
  e[label = "19,646,098\n hospitalisations due to\n cardiovascular diseases"]
  g[label = "278,540\n hospitalisations due to\n tuberculossis"]

  node[ style=invis label=""]
  d1 d2
  subgraph cluster_col1 { peripheries=0  a -> d -> f}
  subgraph cluster_col2 { peripheries=0  d1 -> c -> d2 }
  subgraph cluster_col3 { peripheries=0  b -> e -> g}
}

Giving:
enter image description here

sroush
  • 5,375
  • 2
  • 5
  • 11