6.4.2.14. plotΒΆ

Dispatcher.plot(workflow=False, view=True, nested=True, edge_data=(), node_data=(), node_function=(), draw_outputs=0, node_styles=None, depth=-1, function_module=False, name=None, comment=None, directory=None, filename=None, format='svg', engine=None, encoding=None, graph_attr=None, node_attr=None, edge_attr=None, body=None)[source]

Plots the Dispatcher with a graph in the DOT language with Graphviz.

Parameters:
  • workflow (bool, optional) – If True the latest solution will be plotted, otherwise the dmap.
  • view (bool, optional) – Open the rendered directed graph in the DOT language with the sys default opener.
  • nested (bool, optional) – If False the sub-dispatcher nodes are plotted on the same graph, otherwise they can be viewed clicking on the node that has an URL link.
  • edge_data (tuple[str], optional) – Edge attributes to view.
  • node_data (tuple[str], optional) – Data node attributes to view.
  • node_function (tuple[str], optional) – Function node attributes to view.
  • draw_outputs (int, optional) –

    It modifies the defaults data node and edge attributes to view. If draw_outputs is:

    • 1: node attribute ‘output’ is drawn.
    • 2: edge attribute ‘value’ is drawn.
    • 3: node ‘output’ and edge ‘value’ attributes are drawn.
    • otherwise: node ‘output’ and edge ‘value’ attributes are not drawn.
  • node_styles (dict[str|Token, dict[str, str]]) – Default node styles according to graphviz node attributes.
  • depth (int, optional) – Depth of sub-dispatch plots. If negative all levels are plotted.
  • function_module (bool, optional) – If True the function labels are plotted with the function module, otherwise only the function name will be visible.
  • name (str) – Graph name used in the source code.
  • comment (str) – Comment added to the first line of the source.
  • directory (str, optional) – (Sub)directory for source saving and rendering.
  • filename (str, optional) – File name for saving the source.
  • format (str, optional) – Rendering output format (‘pdf’, ‘png’, ...).
  • engine (str, optional) – Layout command used (‘dot’, ‘neato’, ...).
  • encoding (str, optional) – Encoding for saving the source.
  • graph_attr (dict, optional) – Dict of (attribute, value) pairs for the graph.
  • node_attr (dict, optional) – Dict of (attribute, value) pairs set for all nodes.
  • edge_attr (dict, optional) – Dict of (attribute, value) pairs set for all edges.
  • body (dict, optional) – Dict of (attribute, value) pairs to add to the graph body.
Returns:

A directed graph source code in the DOT language.

Return type:

graphviz.dot.Digraph

Example:

>>> dsp = Dispatcher(name='Dispatcher')
>>> def fun(a):
...     return a + 1, a - 1
>>> dsp.add_function('fun', fun, ['a'], ['b', 'c'])
'fun'
>>> dsp.plot(view=False, graph_attr={'ratio': '1'})
<co2mpas.dispatcher.utils.drw.DspPlot object at 0x...>