下載安裝配置環境變量intall配置環境變量驗證基本繪圖入門graphdigraph一個復雜的例子和python交互
發現好的工具,如同發現新大陸。有時,我們會好奇,論文中、各種專業的書中那么形象的插圖是如何做出來的,無一例外不是對繪圖工具的熟練使用。
下載安裝、配置環境變量
intall
windows版本下載地址:http://www.graphviz.org/Download_windows.php
雙擊msi
文件,然后一直next(記住安裝路徑,后面配置環境變量會用到路徑信息),安裝完成之后,會在windows開始菜單創建快捷信息,默認快捷方式不放在桌面。
配置環境變量
將graphviz安裝目錄下的bin文件夾添加到Path環境變量中:
驗證
進入windows命令行界面,輸入dot -version
,然后按回車,如果顯示graphviz的相關版本信息,則安裝配置成功。
基本繪圖入門
打開windows下的graphviz編輯器gvedit,編寫如下的dot腳本語言,保存成gv格式文本文件。然后進入命令行界面,使用dot命令,將gv文件轉化為png圖形文件。
dot D:/test/1.gv -Tpng -o image.png
graph
graph使用--
描述關系
graph pic1 { a -- b a -- b b -- a [color=blue]}
digraph
使用->
描述關系
digraph pic2 { a -> b a -> b b -> a [style=filled color=blue]}
一個復雜的例子
digraph startgame { label="游戲資源更新流程" rankdir="TB" start[label="啟動游戲" shape=circle style=filled] ifwifi[label="網絡環境判斷是否 WIFI" shape=diamond] needupdate[label="是否有資源需要更新" shape=diamond] startslientdl[label="靜默下載" shape=box] enterhall[label="進入游戲大廳" shape=box] enterroom[label="進入房間" shape=box] resourceuptodate[label="資源不完整" shape=diamond] startplay[label="正常游戲" shape=circle fillcolor=blue] warning[label="提醒玩家是否更新" shape=diamond] startdl[label="進入下載界面" shape=box] //{rank=same; needupdate, enterhall} {shape=diamond; ifwifi, needupdate} start -> ifwifi ifwifi->needupdate[label="是"] ifwifi->enterhall[label="否"] needupdate->startslientdl[label="是"] startslientdl->enterhall needupdate->enterhall[label="否"] enterhall -> enterroom enterroom -> resourceuptodate resourceuptodate -> warning[label="是"] resourceuptodate -> startplay[label="否"] warning -> startdl[label="確認下載"] warning -> enterhall[label="取消下載"] startdl -> enterhall[label="取消下載"] startdl -> startplay[label="下載完成"]}
|
新聞熱點
疑難解答