3

Does anybody know if DiagrammeR currently supports left- and right-justification of node labels when using GraphViz?

Here is a quick example, where I would like to left-justify the text within both of the nodes:

library(DiagrammeR)
grViz("
  digraph test {
    graph [fontsize = 10]

    node [shape = box]
    A [label = 'Foo\nBar']
    B [label = 'Bar\nFoo']

    A -> B
  }
")

I was able to find one resource here for the native GraphViz that uses /l for left-justification, but when I try that within the grViz function I receive an error. For example:

library(DiagrammeR)
grViz("
digraph test {
  graph [fontsize = 10]

  node [shape = box]
    A [label = 'Foo\lBar']
    B [label = 'Bar\lFoo']

  A -> B
}
")

I appreciate any help in advance!

Derek Damron
  • 338
  • 3
  • 9

1 Answers1

4

You need a double backslash to escape the first slash. Here are left and right justified labels:

grViz("
  digraph test {
    graph [fontsize = 10]

    node [shape = box]
    A [label = 'Foo\\lBar\\l']
    B [label = 'Bar\\rFoo\\r']

    A -> B
  }
")
eipi10
  • 91,525
  • 24
  • 209
  • 285