问题
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
回答1:
Pass -Grankdir=LR
option to dot:
pos = nx.graphviz_layout(G, prog='dot', args="-Grankdir=LR")
http://www.graphviz.org/content/command-line-invocation
http://www.graphviz.org/content/attrs#drankdir
来源:https://stackoverflow.com/questions/17204242/horizontal-tree-with-graphviz-layout