Skip to content

Commit

Permalink
Merge pull request #243 from evandrocoan/pydot_tree_orientation
Browse files Browse the repository at this point in the history
Allow to passing "rankdir" to lark/tree.py:pydot__tree_to_png
  • Loading branch information
erezsh authored Oct 1, 2018
2 parents 5f68299 + d8c9e1b commit 4a51ebc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lark/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,17 @@ class SlottedTree(Tree):
__slots__ = 'data', 'children', 'rule', '_meta'


def pydot__tree_to_png(tree, filename):
"Creates a colorful image that represents the tree (data+children, without meta)"
def pydot__tree_to_png(tree, filename, rankdir="LR"):
"""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
"""

import pydot
graph = pydot.Dot(graph_type='digraph', rankdir="LR")
graph = pydot.Dot(graph_type='digraph', rankdir=rankdir)

i = [0]

Expand Down

0 comments on commit 4a51ebc

Please sign in to comment.