Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphviz: Putting a Caption on a Node In Addition to a Label

Tags:

graphviz

dot

In my Graphviz graph (written in DOT), I want each node to have a label, but in addition to that, I want some nodes to have a small caption denoting some other unique value for that node. For example, if this were for a history diagram, a node's label might be something like "Birth of George Washington" and the caption might read "See also: American Revolution."

This is fairly flexible, so the caption doesn't necessarily need to be inside the node, but I do need some other way of putting text that clearly isn't part of the label (e.g. is a different size, possibly a different color) and is in a different location but is still clearly a part of the node.

Is there any way to do this?

like image 557
A. Duff Avatar asked Oct 09 '13 18:10

A. Duff


1 Answers

To place captions outside the node, you may use xlabel:

digraph g {
    forcelabels=true;
    a [label="Birth of George Washington", xlabel="See also: American Revolution"];
    b [label="Main label", xlabel="Additional caption"];
    a-> b;
}

forcelabels=true makes sure no xlabel is omitted.

xlabel for nodes example


A second option is to use HTML-like labels:

digraph g {
    a[label=<Birth of George Washington<BR />
        <FONT POINT-SIZE="10">See also: American Revolution</FONT>>];
}

html like labels example

like image 92
marapet Avatar answered Oct 30 '22 05:10

marapet