This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Attribute Types

Catalogue of the schemas/types/grammars expected by attributes.

The following list gives the legal strings corresponding to values of the given types. The syntax for describing legal type strings is a mixture of literal strings, stdio encodings (e.g., %f for a double), and regular expressions. For regular expressions, (...)* indicates 0 or more copies of the expression enclosed in the parentheses, (...)+ indicates 1 or more, and (...)? denotes 0 or 1 copy.

1 - addDouble

A double with an optional prefix '+'.

If prefixed with +, the double becomes an addition from the default.

2 - addPoint

A point with an optional prefix +.

If prefixed with +, the point becomes a vector addition from the default.

3 - arrowType

Edge arrowhead shape
normal inv
dot invdot
odot invodot
none tee
empty invempty
diamond odiamond
ediamond crow
box obox
open halfopen

The examples above show a set of commonly used arrow shapes. There is a grammar of arrow shapes which can be used to describe a collection of 3,111,696 arrow combinations of the 42 variations of the primitive set of 11 arrows.

The basic arrows shown above contain:

  • most of the primitive shapes (box, crow, diamond, dot, inv, none, normal, tee, vee)
  • shapes that can be derived from the grammar (odot, invdot, invodot, obox, odiamond)
  • shapes supported as special cases for backward-compatibility (ediamond, open, halfopen, empty, invempty).

4 - bool

Boolean; true or false.

5 - clusterMode

  • "local"
  • "global"
  • "none"

6 - color

Colors can be specified using one of five formats:

"#%2x%2x%2x" Red-Green-Blue (RGB)
"#%1x%1x%1x" Shorthand Red-Green-Blue (RGB)
"#%2x%2x%2x%2x" Red-Green-Blue-Alpha (RGBA)
"H[, ]+S[, ]+V" Hue-Saturation-Value (HSV) 0.0 <= H,S,V <= 1.0
"H[, ]+S[, ]+V[, ]A" Hue-Saturation-Value-Alpha (HSVA) 0.0 <= H,S,V,A <= 1.0
string color name

The specification for the RGB and RGBA formats are the format strings used by sscanf to scan the color value. Thus, these values have the form "#RGB" or "#RGBA", where R, G, B, and A each consist of 2 hexadecimal digits, and can be separated by whitespace. As of Graphviz 9.0.0, RGB components can also be given as 1 hexadecimal digit. These are each doubled to form 2-digit components, similar to shorthand HTML colors. HSV colors have the form of 3 or (as of Graphviz 8.0.1) 4 numbers between 0 and 1, separated by whitespace or commas.

String-valued color specifications are case-insensitive and interpreted in the context of the current color scheme, as specified by the colorscheme attribute. If this is undefined, the X11 naming scheme will be used. An initial "/" character can be used to override the use of the colorscheme attribute. In particular, a single initial "/" will cause the string to be evaluated using the default X11 naming. If the color value has the form "/ssss/yyyy", the name yyyy is interpreted using the schema ssss. If the color scheme name is empty, i.e., the color has the form "//yyyy", the colorscheme attribute is used. Thus, the forms "yyyy" and "//yyyy" are equivalent.

At present, Graphviz recognizes the default color scheme X11, and the Brewer color schemes (cf. ColorBrewer). Please note that Brewer color schemes are covered by this license.


Color RGB HSV String
White "#ffffff" "0.000 0.000 1.000" "white"
Black "#000000" "0.000 0.000 0.000" "black"
Red "#ff0000" "0.000 1.000 1.000" "red"
Turquoise "#40e0d0" "0.482 0.714 0.878" "turquoise"
Sienna "#a0522d" "0.051 0.718 0.627" "sienna"

The string value transparent can be used to indicate no color. This is only available in the output formats ps, svg, fig, vmrl, and the bitmap formats. It can be used whenever a color is needed but is most useful with the bgcolor attribute. Usually, the same effect can be achieved by setting style to invis.

7 - colorList

List of (optionally weighted) color values, forming a linear gradient

A colon-separated list of weighted color values: WC(:WC)* where each WC has the form C(;F)? with C a color value and the optional F a floating-point number, 0 ≤ F ≤ 1. The sum of the floating-point numbers in a colorList must sum to at most 1.

NOTE: Gradient fills, described below, are currently only available via *CAIRO or SVG rendering.

If the colorList value specifies multiple colors, with no weights, and a filled style is specified, a linear gradient fill is done using the first two colors. If weights are present, a degenerate linear gradient fill is done. This essentially does a fill using two colors, with the weights specifying how much of region is filled with each color. If the style attribute contains the value radial, then a radial gradient fill is done. These fills work with any shape.

For certain shapes, the style attribute can be set to do fills using more than 2 colors. See the style type for more information.

The following table shows some variations of the yellow:blue color list depending on the style and gradientangle attributes.

See Gallery/gradient for real-world examples of using gradients.

Gradient angle style=filled style=filled fillcolor="yellow;0.3:blue" style=radial

8 - dirType

Edge arrow direction type

For an edge T -> H;

Direction Image

That is, a glyph is drawn at the head end of an edge if and only if dirType is "forward" or "both"; a glyph is drawn at the tail end of an edge if and only if dirType is "back" or "both";

For undirected edges T -- H;, one of the nodes, usually the righthand one, is treated as the head for the purpose of interpreting "forward" and "back".

9 - double

Double-precision floating point number

See Wikipedia: Double-precision floating-point format.

10 - doubleList

List of doubles

A colon-separated list of doubles: "%f(:%f)*" where each %f is a double.

11 - escString

String with backslashed escape sequences

A string allowing escape sequences which are replaced according to the context. For node attributes, the substring \N is replaced by the name of the node, and the substring \G by the name of the graph. For graph or cluster attributes, the substring \G is replaced by the name of the graph or cluster. For edge attributes, the substring \E is replaced by the name of the edge, the substring \G is replaced by the name of the graph or cluster, and the substrings \T and \H by the names of the tail and head nodes, respectively. The name of an edge is the string formed from the name of the tail node, the appropriate edge operator (-- or ->) and the name of the head node. In all cases, the substring \L is replaced by the object's label attribute.

In addition, if the associated attribute is label, headlabel or taillabel, the escape sequences \n, \l and \r divide the label into lines, centered, left-justified, and right-justified, respectively.

Obviously, one can use \\ to get a single backslash. A backslash appearing before any character not listed above is ignored.

12 - int

Integer number

13 - layerList

list of strings separated by characters from the layersep attribute (by default, colons, tabs or spaces), defining layer names and implicitly numbered 1,2,...

14 - layerRange

A list of layers defined by the layers attribute

It consists of a list of layer intervals separated by any collection of characters from the layerlistsep attribute. Each layer interval is specified as either a layerId or a layerIdslayerId, where layerId = "all", a decimal integer or a layer name. (An integer i corresponds to layer i, layers being numbered from 1.)

The string s consists of 1 or more separator characters specified by the layersep attribute.

Thus, assuming the default values for layersep and layerlistsep, if layers="a:b:c:d:e:f:g:h", the layerRange string layers="a:b,d,f:all" would denote the layers a b d f g h.

15 - lblString

Label string

An escString or an HTML label.

16 - outputMode

The order in which nodes and edges are drawn in output.
  • "breadthfirst"

  • "nodesfirst"

  • "edgesfirst"

  • The default "breadthfirst" is the simplest, but when the graph layout does not avoid edge-node overlap, this mode will sometimes have edges drawn over nodes and sometimes on top of nodes.

  • If the mode "nodesfirst" is chosen, all nodes are drawn first, followed by the edges. This guarantees an edge-node overlap will not be mistaken for an edge ending at a node.

  • On the other hand, usually for aesthetic reasons, it may be desirable that all edges appear beneath nodes, even if the resulting drawing is ambiguous. This can be achieved by choosing "edgesfirst".

17 - packMode

How closely to pack together graph components
  • "node"
  • "cluster"
  • "graph"
  • "array(_flags)?(%d)?"

The modes "node", "cluster" or "graph" specify that the components should be packed together tightly, using the specified granularity. A value of "node" causes packing at the node and edge level, with no overlapping of these objects. This produces a layout with the least area, but it also allows interleaving, where a node of one component may lie between two nodes in another component. A value of "graph" does a packing using the bounding box of the component. Thus, there will be a rectangular region around a component free of elements of any other component. A value of "cluster" guarantees that top-level clusters are kept intact. What effect a value has also depends on the layout algorithm. For example, neato does not support clusters, so a value of "cluster" will have the same effect as the default "node" value.

The mode "array(_flag)?(%d)?" indicates that the components should be packed at the graph level into an array of graphs. By default, the components are in row-major order, with the number of columns roughly the square root of the number of components. If the optional flags contains 'c', then column-major order is used. Finally, if the optional integer suffix is used, this specifies the number of columns for row-major or the number of rows for column-major. Thus, the mode "array_c4" indicates array packing, with 4 rows, starting in the upper left and going down the first column, then down the second column, etc., until all components are used.

If a graph is smaller than the array cell it occupies, it is centered by default. The optional flags may contain 't', 'b', 'l', or 'r', indicating that the graphs should be aligned along the top, bottom, left or right, respectively.

If the optional flags contains 'u', this causes the insertion order of elements in the array to be determined by user-supplied values. Each component can specify its sort value by a non-negative integer using the sortv attribute. Components are inserted in order, starting with the one with the smallest sort value. If no sort value is specified, zero is used.

18 - pagedir

Page Direction
  • "BL"
  • "BR"
  • "TL"
  • "TR"
  • "RB"
  • "RT"
  • "LB"
  • "LT"

These specify the 8 row or column major orders for traversing a rectangular array, the first character corresponding to the major order and the second to the minor order. Thus, for "BL", the major order is from bottom to top, and the minor order is from left to right. This means the bottom row is traversed first, from left to right, then the next row up, from left to right, and so on, until the topmost row is traversed.

19 - point

2-dimensional (or 3-dimensional) geometrical point in space

"%f,%f('!')?" representing the point (x,y). The optional '!' indicates the node position should not change (input-only).

If dim=3, point may also have the format "%f,%f,%f('!')?" to represent the point (x,y,z).

20 - pointList

A list of points

points, separated by spaces.

21 - portPos

Port Position: where on a node an edge should be aimed

portPos has the form portname(:compass_point)? or compass_point. If the first form is used, the corresponding node must either have record shape with one of its fields having the given portname, or have an HTML-like label, one of whose components has a PORT attribute set to portname.

If a compass point is used, it must have the form "n","ne","e","se","s","sw","w","nw","c","_". This modifies the edge placement to aim for the corresponding compass point on the port or, in the second form where no portname is supplied, on the node itself. The compass point "c" specifies the center of the node or port. The compass point "_" specifies that an appropriate side of the port adjacent to the exterior of the node should be used, if such exists. Otherwise, the center is used. If no compass point is used with a portname, the default value is "_".

This attribute can be attached to an edge using the headport and tailport attributes, or as part of the edge description as in

digraph {
  node1:port1 -> node2:port5:nw;

Note that it is legal to have a portname the same as one of the compass points. In this case, this reference will be resolved to the port. Thus, if node A has a port w, then headport=w will refer to the port and not the compass point. At present, in this case, there is no way to specify that the compass point should be used.

22 - quadType

Quadtree scheme
  • "normal"
  • "fast"
  • "none"

Using "fast" gives about a 2-4 times overall speedup compared with "normal", though layout quality can suffer a little.

23 - rankdir

Direction to draw directed graphs (one rank at a time)
  • "TB"
  • "LR"
  • "BT"
  • "RL"

Corresponding to directed graphs drawn from top to bottom, from left to right, from bottom to top, and from right to left, respectively.

24 - rankType

Rank constraints on the nodes in a subgraph
  • "same"
  • "min"
  • "source"
  • "max"
  • "sink"

25 - rect

A geometric rectangle in space, defined by two points


The rectangle llx,lly,urx,ury gives the coordinates, in points, of the lower-left corner (llx,lly) and the upper-right corner (urx,ury).

26 - shape

the shape of a node

There are three main types of shapes:

The record-based shape has largely been superseded and greatly generalized by HTML-like labels. That is, instead of using shape=record, consider using shape=none and an HTML-like label.

27 - smoothType

Values are:

  • "none"
  • "avg_dist"
  • "graph_dist"
  • "power_dist"
  • "rng",
  • "spring"
  • "triangle"

28 - splineType

spline ( ';' spline )*

  • where spline = (endp)? (startp)? point (triple)+
  • and triple = point point point
  • and endp = "e,%f,%f"
  • and startp = "s,%f,%f"

If a spline has points p₁ p₂ p₃ ... pₙ, (n = 1 (mod 3)), the points correspond to the control points of a cubic B-spline from p₁ to pₙ. If startp is given, it touches one node of the edge, and the arrowhead goes from p₁ to startp. If startp is not given, p₁ touches a node. Similarly for pₙ and endp.

29 - startType

How to initially layout nodes

Has the syntax (style)?(seed)?.

If style is present, it must be one of the strings:

  • "regular": place nodes regularly about a circle
  • "self": run an abbreviated version of neato to obtain the initial layout
  • "random": place nodes randomly in a unit square.

If seed is present, it specifies a seed for the random number generator. If seed is a positive number, this is used as the seed. If it is anything else, the current time, and possibly the process id, is used to pick a seed, thereby making the choice more random. In this case, the seed value is stored in the graph.

If the value is just "random", a time-based seed is chosen.

Note that input positions, specified by a node's pos attribute, are only used when the style is "random".

30 - string

Text; a sequence of characters.

See also escString, text with escape-sequences.

31 - style

styleItem ( ',' styleItem )*

where styleItem = name or name'('args')'
and args = name ( ',' name )*

and name can be any string of characters not containing a space, a left or right parenthesis, or a comma. Whitespace characters are ignored.

NOTE: The styles tapered, striped and wedged are only available in release 2.30 and later.

The recognized style names are,

For nodes and edges:

  • "dashed"
  • "dotted"
  • "solid"
  • "invis"
  • "bold"

For edges only:

  • "tapered"

For nodes only:

  • "filled"
  • "striped"
  • "wedged"
  • "diagonals"
  • "rounded"

For clusters:

  • "filled"
  • "striped"
  • "rounded"

The style "radial" is recognized for nodes, clusters and graphs, and indicates a radial-style gradient fill if applicable.

The style "striped" causes the fill to be done as a set of vertical stripes. The colors are specified via a colorList, the colors drawn from left to right in list order. Optional color weights can be specified to indicate the proportional widths of the bars. If the sum of the weights is less than 1, the remainder is divided evenly among the colors with no weight. Note: The style "striped" is only supported with clusters and rectangularly-shaped nodes.

The style "wedged" causes the fill to be done as a set of wedges. The colors are specified via a colorList, with the colors drawn counter-clockwise starting at angle 0. Optional color weights are interpreted analogously to the striped case described above. Note: The style "wedged" is allowed only for elliptically-shaped nodes.

The following tables illustrate some of the effects of the style settings. Examples of tapered line styles are given below. Examples of linear and radial gradient fill can be seen under colorList.

Basic style settings for nodes
solid dashed dotted
bold rounded diagonals
filled striped wedged
Basic style settings for edges
solid dashed
dotted bold
Basic style settings for clusters
solid dashed dotted bold
rounded filled striped

The effect of style=tapered depends on the penwidth, dir, arrowhead and arrowtail attributes. The edge starts with width penwidth and tapers to width 1, in points. The dir attribute determines whether the tapering goes from tail to head (dir=forward), from head to tail (dir=forward), from the middle to both the head and tail (dir=both), or no tapering at all (dir=none). If the dir is not explicitly set, the default for the graph type is used (see dir). Arrowheads and arrowtails are also drawn, based on the value of dir; to avoid this, set arrowhead and/or arrowtail to "none".

Note: At present, the tapered style only allows a simple filled polygon. Additional styles such as dotted or dashed, or multiple colors supplied via a colorList are ignored.

The following table illustrates the style=tapered with penwidth=7 and arrowtail=none.

dir \ arrowhead normal none

Additional styles are available in device-dependent form. Style lists are passed to device drivers, which can use this to generate appropriate output.

The style attribute affects the basic appearance of nodes, edges and graphs, but has no effect on any text used in labels. For this, use the fontname, fontsize and fontcolor attributes, or the <FONT>, <B>, <I>, etc. elements in HTML-like labels.

The setlinewidth style value can be used for more control over the width of node borders and edges than is allowed by bold. This style value takes an argument, specifying the width of the line in points. For example, style="bold" is equivalent to style="setlinewidth(2)". The use of setlinewidth is deprecated; one should use the penwidth attribute instead.

32 - viewPort

Clipping window on final drawing

Format: "%lf,%lf,%lf,%lf,%lf" or "%lf,%lf,%lf,'%s'"

The viewPort W,H,Z,x,y or W,H,Z,N specifies a viewport for the final image. The pair (W,H) gives the dimensions (width and height) of the final image, in points.

The optional Z is the zoom factor, i.e., the image in the original layout will be W/Z by H/Z points in size. By default, Z is 1.

The optional last part is either a pair (x,y) giving a position in the original layout of the graph, in points, of the center of the viewport, or the name N of a node whose center should used as the focus.

By default, the focus is the center of the graph bounding box, i.e., (bbx/2,bby/2), where "bbx,bby" is the value of the bounding box attribute bb.

Sample values: 50,50,.5,'2.8 BSD' or 100,100,2,450,300. The first will take the 100x100 point square centered on the node 2.8 BSD and scale it down by 0.5, yielding a 50x50 point final image.

33 - xdot

List of graphical operations in Graphviz's xdot language.

xdot is a custom Graphviz language invented by Emden Gansner, describing ellipses, polygons, polylines, beziers, text, images, colors, gradients, fonts, and styles.

Example: c 7 -#ff0000 p 4 4 4 36 4 36 36 4 36 renders a red square.

For more information on the xdot format, see: