rgraphvizquartodiagrammersystemdynamics

Place xlabel below node in DiagrammeR / Graphviz


I want to create system dynamics graphics for a course material that I write in Quarto, ideally with Graphviz (R package DiagrammeR). To be as close as possible to the standards, I want to use a "flow symbol", for example an hourglass character. In the attempt below I use a special character, but a method with two triangles would also be fine. The problem is now, how to place an additional label below the flow symbol. I tried three different ideas:

  1. use an edge directly from A to B and somehow add the hourglass in the middle,
  2. add an additional overlapping edge directly from A to B, but then the arrows get curved to avoid overlap,
  3. use xlabel that seems to be the easiest (see below) even if it needs tricks to reduce the font size. However, I want to have the xlabel "growth" in the middle and a little bit lower, below the hourglass.

Here is my code:

library(DiagrammeR)

graph_code <- '
digraph {
  graph [rankdir = "LR"]
  
  node [shape = rect]
  A  B
  
  node [shape=none, width=0, height=0, fontsize=20, fixedsize=true, forcelabels=true]
  C [label="&#10710;", xlabel=<<FONT POINT-SIZE="8">growth</FONT>>]
  
  A -> C [dir = none, color = "blue"]
  C -> B [dir = left, color = "blue"]

}
'

grViz(graph_code)

enter image description here


Solution

  • This combines the label & xlabel into an html table.

    digraph {
      graph [rankdir = "LR"]  
      node [shape = rect]
      A  B
      
      node [shape=none, Xfontsize=20]
      // the height may need to be tweaked, based on actual fonts used
      C [label=<<table cellpadding="0" border="0" cellspacing="0"><tr><td height="12"></td></tr><tr><td><FONT POINT-SIZE="20">&#10710;</FONT></td></tr><tr><td>growth</td></tr></table>>]
      
      A -> C [dir = none, color = "blue" headclip=false]
      C -> B [dir = left, color = "blue" tailclip=false]
    }
    

    Giving:
    enter image description here