Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 381
OrLi Avatar asked Sep 20 '25 09:09

OrLi


1 Answers

You can use rankdir like this:

gv.graph_attr["rankdir"] = "LR"
like image 193
arcGuesser Avatar answered Sep 22 '25 22:09

arcGuesser