I am using diagrammeR
grViz
to construct a flow chart. I would like to specify the order of some of the nodes that have the same rank. In the following chart, I would like to have Node 1 in the center rather than on the left. In addition, I would like to have "Node 2" underlined, but not "extra detail". Here is the code:
library("DiagrammeR")
grViz("
digraph CFA {
# Multiple level nodes
node [shape = rectangle, color=CornflowerBlue]
a [label = 'Node 1' ];
node [shape = ellipse, color=CornflowerBlue]
T1 [label = 'Node 2\\nextra detail'];
T2 [label = 'Node 3'];
{rank = same; a T1 T2}
# Connect nodes with edges and labels
a -> T1
a -> T2
}
")
Any help would be much appreciated. Also, if there are resources to help me along with these customization issues in diagrammeR
, please include a link.
there are several ways to order the nodes. The easiest here is perhaps to have the edge T2 -> a
in this order (rather than a -> T2
), so node T2
is first and then use dir=back
to reverse the arrow. You can use html to underline the node label. (also have to use break, <br/>
, instead of newline,\n
)
grViz("
digraph CFA {
a [label = 'Node 1', shape = rectangle, color=CornflowerBlue ];
node [shape = ellipse, color=CornflowerBlue]
T1 [label = <Node 2 <br/> <u>extra detail</u>>];
T2 [label = 'Node 3'];
{rank = same; a T1 T2}
# Connect nodes with edges and labels
a -> T1
T2 -> a[dir=back]
}
")
From comment: Is there a way to make a portion of the text in a node a different color (e.g. just the "extra detail", but not "Node 2")?
Yes, from the html link above you can "sets the color of the font within the scope of FONT.../FONT". So for example, change the label of T1
to
label = <Node 2 <br/> <font color='red'> <u>extra detail</u> </font> >
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