I created a graphviz
plot to visualize a decision tree. Now I would like to add labels (e.g. True
, False
) to the graph on all edges.
I was using regex to manipulate the .dot
file, adding the labels True
and False
manually. Resulting in the following file
digraph Tree {
node [shape=box, style="rounded", color="black", fontname=helvetica] ;
edge [fontname=helvetica] ;
0 [label="s5 smaller
or equal to 0.0"] ;
1 [label="bmi smaller
or equal to 0.0"] ;
0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ;
3 [label="value = 110.6"] ;
1 -> 3 [headlabel="True"] ;
4 [label="value = 161.0"] ;
1 -> 4 [headlabel="False"] ;
2 [label="bmi smaller
or equal to 0.0"] ;
0 -> 2 [labeldistance=2.5, labelangle=-45, headlabel="False"] ;
5 [label="value = 174.0"] ;
2 -> 5 [headlabel="True"] ;
6 [label="value = 237.7"] ;
2 -> 6 [headlabel="False"] ;
}
This produces the following plot:
However, the labels don’t get nicely arranged (the arrow cuts-off the label) and I would like to format the text accordingly. Is there a way this can be done in graphviz
plots?
Thank you!