graphviz官網:http://www.graphviz.org/
背景:有畫圖需要,之前見到別人用graphviz畫,畫出來的圖漂亮,且自動幫你排版安排布局,所以自己想嘗試用它畫。
其中遇到的幾個問題
- win系統下載msi安裝包后進行安裝,安裝不成功,報錯信息是win電腦卻少什么包,最后轉向Mac畫圖。
- 找到兩個graphviz online的網站(http://www.webgraphviz.com/ 和),都不太好用,不是對中文支持不好,就是稍微復雜一些的圖他就畫不出來了。
- Mac 的安裝了graphviz,但是你要先保存.dot文件,編碼方式選為utf-8,再用Graphviz打開,就可以支持中文。
- 對於如何調字體顏色,大小,形狀,標簽等,參考官網幫助頁面都可以搞定。
為什么用這個工具畫圖?
- 自動幫你排版
- 如果圖要改動,后續維護簡單
- 畫出來的圖好看,逼格高
最后放一張自己畫的圖

畫圖用的代碼:
digraph ER {
//size = "9, 15";//圖片大小
//fontsize=22
compound=true;
node [shape=ellipse,fontname=微軟雅黑,labelfontsize=9,fontsize=28]; u89; c1;
node [shape=box,style=filled,color=palegreen1]; a45;y78;h8;
node [shape=diamond,style=filled,color=grey92];"b1";"p9";
fontsize=25
a [shape=diamond,style=filled,color=lgrey92,label="a1"];
b [shape=diamond,style=filled,color=grey92,label="a2"];
c [shape=diamond,style=filled,color=grey92,label="a3"];
d [shape=diamond,style=filled,color=grey92,label="a4"];
u89 -> a45;
a45 -> "b1"[label="",len=1.00];
"b1" -> a [label="是",len=1.00,fontname=微軟雅黑,fontsize=25];
"b1" -> b [label="否",len=1.00,fontname=微軟雅黑,fontsize=25];
subgraph cluster_0 {
style=filled;
color=bisque;
label = "b2";
fontname=微軟雅黑
node [shape=diamond,style=filled,color=grey92];"p9";
a [shape=diamond,style=filled,color=grey92,label="d7"];
c [shape=diamond,style=filled,color=grey92,label="f17"];
m [shape=box,label=y78,style=filled,color=palegreen1];
a -> m [label="是",len=1.00,fontname=微軟雅黑,fontsize=25];
a -> "p9" [label="否",len=1.00,fontname=微軟雅黑,fontsize=25];
"p9" -> c [label="是",len=1.00,fontname=微軟雅黑,fontsize=25];
"p9" -> m [label="否",len=1.00,fontname=微軟雅黑,fontsize=25];
c -> m [label="是",len=1.00,fontname=微軟雅黑,fontsize=25];
c -> h8 [label="否",len=1.00,fontname=微軟雅黑,fontsize=25];
}
subgraph cluster_1 {
//graph[rank=min;width=11;height=26];
label = "aa";
fontname=微軟雅黑;
style = filled;
color=lightblue;
b [shape=diamond,style=filled,color=grey92,label="d7"];
d [shape=diamond,style=filled,color=grey92,label="f17"];
n [shape=box,label=y78,style=filled,color=palegreen1];
b -> n [label="是",len=1.00,fontname=微軟雅黑,fontsize=25];
b -> d [label="否",len=1.00,fontname=微軟雅黑,fontsize=25];
d -> n [label="是",len=1.00,fontname=微軟雅黑,fontsize=25];
d -> y78 [label="否",len=1.00,fontname=微軟雅黑,fontsize=25];
}
m -> c1;
n -> c1;
y78 -> c1;
h8 -> c1;
}
總結:多動手,多積累實戰經驗。博客園也有其他說這個工具的文章,
利用Graphviz 畫結構圖
Graphviz-Gdot語言學習
等。
