Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphviz - Python : Making node shape into double ellipse with Graphviz

I am using Graphviz 0.5.2 with in my python script, which is similar to this

from graphviz import Digraph
dot = Digraph()
dot.node('A', 'King Arthur', shape='ellipse')
dot.node('B', 'Sir Bedevere the Wise', shape='ellipse')
dot.node('L', 'Sir Lancelot the Brave', shape='ellipse')

dot.edges(['AB', 'AL'])
dot.edge('B', 'L', constraint='false')
dot.render('test-output/round-table.gv', view=True)

it renders this:

enter image description here

By default the shape of the node is an ellipse/oval but I would like to make it a double ellipse, there is a double circle shape but not an ellipse.

I have tried peripheries = 2 but i'm not sure of the right place to put it.

like image 728
Meryem Avatar asked Sep 16 '25 09:09

Meryem


1 Answers

Apply peripheries to the node properties e.g.

graph ethane {
node[ peripheries=5];
     C_0 -- H_0 [type=s];
     C_0 -- H_1 [type=s];
     C_0 -- H_2 [type=s];
     C_0 -- C_1 [type=s];
     C_1 -- H_3 [type=s];
     C_1 -- H_4 [type=s];
     C_1 -- H_5 [type=s];
 }

See chart

In python if I understand the examples

dot.node_attr['peripheries']='5' #whole graph
n.attr['peripheries']='5' #any single node n

https://github.com/pygraphviz/pygraphviz/blob/master/examples/star.py

like image 163
awiebe Avatar answered Sep 18 '25 00:09

awiebe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!