StylingΒΆ
Use the graph_attr
, node_attr
, and edge_attr
arguments
of the Graph
and Digraph
constructors to change
the default attributes for your graph, nodes, and edges.
>>> import graphviz
>>> ps = graphviz.Digraph('pet-shop', node_attr={'shape': 'plaintext'})
>>> ps.node('parrot')
>>> ps.node('dead')
>>> ps.edge('parrot', 'dead')
After creation, the graph_attr
, node_attr
, and
edge_attr
attributes be edited on instances:
>>> ps.graph_attr['rankdir'] = 'LR'
>>> ps.edge_attr.update(arrowhead='vee', arrowsize='2')
>>> print(ps.source)
digraph "pet-shop" {
graph [rankdir=LR]
node [shape=plaintext]
edge [arrowhead=vee arrowsize=2]
parrot
dead
parrot -> dead
}