I am writing a Python script to generate a network graph using graphviz. Some of my nodes represents injection into a network and I am wondering if it is possible to have a Pie-Chart inside some of the nodes.
Python code for a simple two node network is following:
import graphviz as gv
g1 = gv.Graph(format='svg')
g1.node('A')
g1.node('B')
g1.edge('A', 'B')
filename = g1.render(filename='img/g1')
I let the PyGraphViz implementation up to you. But to answer to the core of your question, since graphviz 2.30, you can use the wedged
style for nodes, to achieve the desired result. Here is an example in plain dot:
digraph G {
{
node [shape=circle style=wedged fillcolor="red;0.3:green;0.6:orange"]
A
node [style=solid fillcolor="white" ]
B
C
}
B -> A
B -> C
}
The list of colors is expressed as a colon separated list. The value after the **semi-colon* in the weight of the given color. The sum of all weights must be equal to 1.0. See the colorList attribute