Using raw DOTΒΆ
To render a ready-made DOT source code string
(instead of assembling one with the higher-level interface
of Graph
or Digraph
),
create a graphviz.Source
object holding your DOT string:
>>> import graphviz
>>> src = graphviz.Source('digraph "the holy hand grenade" { rankdir=LR; 1 -> 2 -> 3 -> lob }')
>>> src
<graphviz.sources.Source object at 0x...>
Use the render()
method to save and render it:
>>> doctest_mark_exe() # skip this line
>>> src.render('doctest-output/holy-grenade.gv').replace('\\', '/')
'doctest-output/holy-grenade.gv.pdf'
>>> doctest_mark_exe() # skip this line
>>> src.render('doctest-output/holy-grenade.gv', view=True).replace('\\', '/')
'doctest-output/holy-grenade.gv.pdf'