自由绘图软件中有两大神器: gnuplot graphviz. 前者一般用来可视化你的数据, 比如描绘函数sin的曲线之类的, 对我来说其实用的不多. 而后者在软件领域使用得相对频繁, graphviz 主要用来显示一些结构化信息, 比如画画流程图, 网络拓扑图, 函数调用序列之类的, 很是实用. 这里主要介绍一下graphviz.

我之所以说他俩是神器, 因为他们提供非常方便的命令行接口, 可以完成自动化绘图功能. 另外你不必仔细考虑绘图的图形细节, 只需要把握处理流程或者拓扑结构就可以了. 这是一种"所思即所得"的绘图工具, 当然, 你很快就想到了, 它们一定也和latex, make这套系统结合得很好.

比如你想画这样一副图:

graphviz_cluster.png

这段代码就可以胜任:

digraph G {
 
        subgraph cluster_0 {
                style=filled;
                color=lightgrey;
                node [style=filled,color=white];
                a0 -> a1 -> a2 -> a3;
                label = "process #1";
        }
 
        subgraph cluster_1 {
                node [style=filled];
                b0 -> b1 -> b2;
                label = "process #2";
                color=blue
        }
        start -> a0;
        start -> b0;
        a1 -> b2 [color=red, label="call it", fontcolor=red];
        b2 -> b0 [style=dotted];
        a3 -> end;
        b2 -> end;
 
        start [shape=Mdiamond];
        end [shape=Msquare];
}

然后你可以用make来管理它:

?View Code MAKEFILE
DOT=d:/program/Graphviz/bin/dot.exe
 
all: graphviz_cluster.png
 
graphviz_cluster.png: graphviz_cluster.dot
$(DOT) -Tpng $< -o $@

BTW, 后来一朋友看了这篇短文, 说, 本来也想用这工具画画图, 显示数据的, 不过后来都用python替代. 言者无心, 听者有意. 的确多掌握工具, 不如只精通一种脚本呢, 同学们来学python吧~ 的确很火热, 很流行, 也很强大.