Search notes:

Graphviz - label attribute

The label attribute specifies the text that is shown with the following elements: node, edge and cluster.
The label attribute has no effect on subgraphs, see this demonstration.
The type of the label attribute is lblString.
In record based nodes, the value of the label may contain some special instructions like the vertical bar or curly braces.
The font that is used to render a label is controlled with the fontname attribute.

HTML like lables

Typically, the label is just a string that is enclosed in quotes (label = "some text").
However, if angle brackes are used (label = < <table> … >), Graphviz renders labels with HTML tags.

Giving a graph a title

A label that is not part of an edge or a node gives a title to a graph.
By default, this title is rendered at the graph's bottom. In order to render it on the top, the value of labelloc needs to be set to t.
digraph {

   label     = "The title of the graph"
   labelloc  =  t // t: Place the graph's title on top.
   fontsize  = 30 // Make title stand out by giving a large font size
   fontcolor = blue

   node   [ shape = rect ]

   node_1 [ label = "text for a first node" ]
   node_2 [ label = "text for a second node" ]

// Start label text with a space so
// it doesn't get rendered too close to the edge.
   node_1 -> node_2 [ label = " label for edge"]

}
Github repository about-Graphviz, path: /attributes/label/simple.dot

See also

Graphviz attributes

Index