I am using the following code to create a pygraphviz
graph. But is it possible to make it render latex math equations (see Figure 1)? If not, is there an alternative python library that plots similar graphs but supports latex rendering ?
import networkx as nxfrom networkx.drawing.nx_agraph import to_agraphG=nx.DiGraph()
G.add_node(1,color='blue',style='filled',fillcolor='white',shape='square', label="$3x+2$")
G.add_node(2)
G.add_node(3)
G.add_edge(1, 2)
G.add_edge(1, 3)
G.add_edge(3, 4)A = to_agraph(G)
A.layout('dot')
A.draw('test1.png')
This results in the following figure
Figure 1