horizontal tree with graphviz_layout

拟墨画扇 提交于 2019-12-12 10:54:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!