我使用以下代码来创建一个pygraphviz图。但是有没有可能让它呈现latex数学方程(参见图1)?如果没有,是否有其他python库可以绘制类似的图形,但支持latex渲染?
import networkx as nx
from networkx.drawing.nx_agraph import to_agraph
G=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')结果如下图所示

图1
发布于 2016-03-07 04:38:07
也许https://dot2tex.readthedocs.org/en/latest/会为你工作?试一试
import dot2tex
texcode = dot2tex.dot2tex(A.to_string(), format='tikz', crop=True)https://stackoverflow.com/questions/35830447
复制相似问题