Graphviz Graphs from text
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
digraph G { a -> b }
graph G { a -- b }
dot -Tpng in.gv -o out.png
a [label="Start"]
rankdir=LRa -> b [label="yes"]
{rank=same; a; b}
subgraph cluster_x { }
Concepts
- DOT text .gv / .dot
- Layout positions
- Output svg, png, pdf
Command line
dot -T<fmt> <file> -o <out>
dot -Tsvg <file> > <out>.svg
dot -Kneato -Tpng <file> -o <out>
neato / fdp / circo / twopi
dot -Gkey=value <file>
dot -Vdot -T:Graph Basics
digraph G { ... }
strict digraph G { ... }
a -> b -> c
a -> {b c d}a [label="Name"]
a -> b [label="x"]
// ... /* ... */ # ...
"two words"
label="line1\nline2"
node [shape=box]
graph [bgcolor=white]
Nodes
shape=boxshape=circle / diamond
shape=recordshape=plaintext / none
style=filled fillcolor=<c>
color=<c> penwidth=<n>
fontname=<f> fontsize=<n>
URL="<url>"
Edges
style=dashed / dotted
dir=bothdir=nonearrowhead=<type>
constraint=false
weight=<n>
splines=orthoa:p1 -> b:p2Layout and Groups
rankdir=LR{rank=same; a; b}
subgraph cluster_<n> { ... }
label="<t>"; style=filled;
nodesep=<in> ranksep=<in>
ratio=<r> size="<w>,<h>"
overlap=falselayout=neatonewrank=true| Engine | Best for |
|---|---|
dot |
Layered hierarchies, flows |
neato |
Spring model, small graphs |
fdp |
Springs with clusters |
sfdp |
Very large graphs |
circo |
Circular layouts |
twopi |
Radial from a root |
Colours and Labels
color="#rrggbb"
label=<<b>bold</b>>
label=<<table>...</table>>
Recipes
digraph G { rankdir=LR; node [shape=box, style=rounded]; start -> build -> test -> deploy; test -> build [label="fail", style=dashed];}
digraph G { subgraph cluster_a { label="Backend"; api; db; } web -> api -> db; {rank=same; web; cache}}
digraph G { node [shape=record]; t [label="{name|<id>id|<fk>owner}"]; u [label="{user|<id>id}"]; t:fk -> u:id;}
for f in *.gv; do dot -Tsvg "$f" -o "${f%.gv}.svg"done



