How do I add names (or labels) to a DiagrammeR GraphViz layout? I'd like to add names to each dot below, and I'd like them to be in an organized fashion, not overlapping anything else, a la ggrepel
style. You can use any names you wish for the following example. This is going to basically be an org chart. Thank you.
library(DiagrammeR)
grViz("
digraph neato {
graph [layout = neato]
node [shape = circle,
style = filled,
color = grey,
label = '']
node [fillcolor = red]
a
node [fillcolor = green]
b c d
node [fillcolor = orange]
edge [color = grey]
a -> {b c d}
b -> {e f g h i j}
c -> {k l m n o p}
d -> {q r s t u v}
}")
after the node, add [label = 'your label']
. You can declare a node's label separately or inline.
grViz("
digraph neato {
graph [layout = neato]
node [shape = circle,
style = filled,
color = grey,
label = '']
node [fillcolor = red]
a [label='a']
node [fillcolor = green]
b c d
node [fillcolor = orange]
l [label = 'llllllllllllll', fixedsize = true, width = 0.5]
edge [color = grey]
a -> {b c d}
b -> {e f g h i j}
c -> {k l m n o [label = 'o'] p [label = 'p']}
d -> {q r s t u v}
}")