in python, with networkx. I can plot a vertical tree with :
g=nx.balanced_tree(2,4)
pos = nx.graphviz_layout(g, prog='dot')
nx.draw(g,pos,labels=b_all, node_size=500)
plt.show()
similar to
[root]
|
| |
node node
how I can plot a horizontal tree ?
-- node
[root] -
-- node
Pass -Grankdir=LR
option to dot:
pos = nx.graphviz_layout(G, prog='dot', args="-Grankdir=LR")
https://graphviz.org/doc/info/command.html
https://graphviz.org/doc/info/attrs.html#d:rankdir
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With