Allow any graph attribute in `pydot__tree_to_png`.

Keeping the explicit `rankdir="LR"` as default, add `kwargs`
to `pydot__tree_to_png` and `pydot.Dot` so that all graphviz
attributes are available for the graph.
This commit is contained in:
fbindel 2019-05-09 14:41:41 +02:00
parent 4d8301f73c
commit 09afcfcfc7
1 changed files with 6 additions and 4 deletions

View File

@ -141,17 +141,19 @@ class SlottedTree(Tree):
__slots__ = 'data', 'children', 'rule', '_meta'
def pydot__tree_to_png(tree, filename, rankdir="LR"):
def pydot__tree_to_png(tree, filename, rankdir="LR", **kwargs):
"""Creates a colorful image that represents the tree (data+children, without meta)
Possible values for `rankdir` are "TB", "LR", "BT", "RL", corresponding to
directed graphs drawn from top to bottom, from left to right, from bottom to
top, and from right to left, respectively. See:
https://www.graphviz.org/doc/info/attrs.html#k:rankdir
top, and from right to left, respectively.
`kwargs` can be any graph attribute (e. g. `dpi=200`). For a list of
possible attributes, see https://www.graphviz.org/doc/info/attrs.html.
"""
import pydot
graph = pydot.Dot(graph_type='digraph', rankdir=rankdir)
graph = pydot.Dot(graph_type='digraph', rankdir=rankdir, **kwargs)
i = [0]