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!
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
  }
")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With