6

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
JuanPablo
  • 23,792
  • 39
  • 118
  • 164

1 Answers1

12

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

t1m0
  • 735
  • 1
  • 7
  • 14
falsetru
  • 357,413
  • 63
  • 732
  • 636