Graphviz (DOT) Captions

myahya picture myahya · Jan 17, 2011 · Viewed 14.8k times · Source

I need to print a large number of graphs using Graphviz DOT. To distinguish which input each graph corresponds to, I want to also have a caption for each graph. Is there anyway to embed this into the DOT representation of the graphs.

Answer

marapet picture marapet · Jan 17, 2011

You can use label to add a caption to the graph.

Example:

digraph {
    A -> B;
    label="Graph";
    labelloc=top;
    labeljust=left;
}

labelloc and labeljust can be used to determine top/bottom and left/right position of the graph label.

All the details and other attributes that can be used to modify the label (font etc) in the graphviz attribute reference.

Tip: Define the graph label end of your dot file, otherwise subgraphs will inherit those properties.