11.5.6 Arrow Labels and Markers

You can add labels and markers to arrows/lines. Markers are dots, tick marks, etc. along the line.

To add a single label, simply add a label to the arrow using the label attribute or the colon-label syntax as for blocks: a->b: This is the label.; The position of the label can be set using the label.align attribute, with the values of 0 and 100 representing the start and end of the arrow (with values proportionally in between, but you can also have negative values or above 100%). With label.pos you can set how the label is placed in relation to the arrow line. It can take one of left, right, above, below or center, the latter meaning onto the line.

To add a single marker, use the label.align to set its position and optionally the marker.type attribute to set its shape, using any of the arrowhead types listed in Arrow and Line Attributes. You can apply to any of the arrowhead attributes to marker.*, specifically marker.type, marker.gvtype (to set the arrowhead type in graphviz style), marker.size and marker.color.

You can add more labels by specifying them in curly braces after the arrow. Their syntax is as follows.

[mark] [extend] <position> [<attributes>];

<position> is specified as a) a percentage number (followed by a percentage sign); b) a percentage number (followed by a percentage sign) followed by an optional sign and an offset number in pixels; or c) an offset number in pixels (no percentage sign). The percentage number is interpreted so that 0% means the start of the arrow, 100% means its entire length. A positive percentage number is measured from the start of the arrow forward, while a negative value means measuring it from the end of the arrow backwards. Thus, 99% is the same as -1%. The offset value is then added/substracted from this position (interpreted in pixels). If only a pixel value is specified, a positive value is measured from the start of the arrow forward, a negative value backward.

If you specify extend, the start of the measurement changes: for positive values we start to measure from the end of the arrow forward (beyond the end of the arrow), for negative values we start measuring from the start of the arrows (before the start). It is actually simpler than it sounds, here are a few examples.

exH6_cshexH6

Adding the mark keyword before the position will add a marker at the designated position. In this case there is no need to specity a label, if you just want the marker. The default type for markers is marker.gvstyle=tick, which is a thin line perpendicular to the arrow line.

Among attributes you can use marker.* to set the marker style; label, text.*, label.pos and label.orient to specify the label and its details; and line.*, fill.* and shadow.* to specify a box around the label.

As a shorthand, you can omit the curly braces and simply specify the labels after the arrow specification.

The label orientation can be influenced with label.orient the same way as for blocks, but for arrow labels, two more values are available: tangent and tangent_upside_down. These rotate the label to match the tangent of the arrow line at the label position. Layout makes an effort to lay out the label to be readable left-to-right, but you can also request it to be upside down with tangent_upside_down.

exJ8_cshexJ8