OrLi
OrLi

Reputation: 51

graphviz on colab - how to use rankdir

Using colab I'm trying to print a graph "Input -> program -> results" from left to right, but it print top to bottom. My code:

from graphviz import *
gv = Digraph('G', filename='process.gv')
gv.rankdir='LR'
gv.edge('input', 'program')
gv.edge('program', 'results')
gv.node('program', shape='box3d')
gv

I also tried (instead of 3rd line):

gv.graph('graph', {})['rankdir'] = 'LR'

or

gv.rankdir('LR')

But it returned error messages

Would very much appreciate anyone's help.

Upvotes: 4

Views: 241

Answers (1)

arcGuesser
arcGuesser

Reputation: 136

You can use rankdir like this:

gv.graph_attr["rankdir"] = "LR"

Upvotes: 4

Related Questions