FormatsΒΆ

To use a different output file format than the default PDF, you can use the format argument when creating your Graph or Digraph object:

>>> import graphviz

>>> g = graphviz.Graph(format='png')

You can also change the format attribute on an existing graph object:

>>> doctest_mark_exe()  # skip this line

>>> dot = graphviz.Digraph('hello')
>>> dot.edge('hello', 'world')
>>> dot.format = 'svg'

>>> dot.render(directory='doctest-output').replace('\\', '/')
'doctest-output/hello.gv.svg'