Skip to content

Commit

Permalink
Allow to pass to lark/tree.py pydot__tree_to_png the pydot tree
Browse files Browse the repository at this point in the history
shaping. For example, passing "TB" instead of "LR" makes the tree
to be draw vertically instead of horizontally.

https://stackoverflow.com/questions/29003465/pydot-graphviz-how-to-order-horizontally-nodes-in-a-cluster-while-the-rest-of-t
  • Loading branch information
evandrocoan committed Oct 1, 2018
1 parent 5f68299 commit 91a5a5d
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)

i = [0]

Expand Down

0 comments on commit 91a5a5d

Please sign in to comment.