graphviz可以使用简单易用的dot语言自动绘制各种逻辑图。
digraph Tree {
node [shape=box, style="filled, rounded", color="black",fontname="Microsoft YaHei"] ;
edge [color="red",fontname="Microsoft YaHei"] ;
0 [label="hello", fillcolor="yellow"] ;
1 [label="world", fillcolor="#e5813974"] ;
2 [label="你好",fillcolor="#008080"];
3 [label="世界",fillcolor="#ff6666"];
0->1[label="哈哈哈"];
1->{2,3}[label="成功了",color="green",fontcolor="gray"];
}
写好上述脚本后,保存为xxx.dot文件,如有中文,最好设置其中的fontname为中文字体,否则可能出现乱码,文件保存格式选择utf-8编码。
然后在命令行内运行:
dot -Tpdf xxx.dot -o xxx.pdf
图像就将保存到pdf文件。
或者:
dot -Tpng xxx.dot -o xxx.png
图像保存为png文件。