Graphviz安裝+入門使用教學

第一篇技術分享文

篇幅有限(才怪) ,簡單分享


因為第一份工作會設計Web,所以想學習用視覺化呈現架構,

第一個搜尋與接觸到的是這個:Graphviz

網址:http://www.graphviz.org/



[安裝]

我是下載windows版本的,在jupyter notebook上操作

首先;

1.!pip install graphviz

2.到環境變數設定  (我是Anaconda上的套件)

C:\Users\[user]\Anaconda3\pkgs\graphviz-2.38.0-4\Library\bin\graphviz ※ user名稱要改


[使用]

from graphviz import Digraph

dot = Digraph(comment='The Round Table')

dot.node('A', 'King Arthur')
dot.node('B', 'Sir Bedevere the Wise')
dot.node('L', 'Sir Lancelot the Brave')

dot.edges(['AB', 'AL'])
dot.edge('B', 'L', constraint='false')

dot.render('test-output/round-table.gv', view=True) #匯出pdf檔案

[結果]





非常easy!可以嘗試看看

環境變數那邊可能會有點混亂,不過有加上去問題就解決了

[參考]

官方提供程式碼:https://github.com/xflr6/graphviz

概念教學:https://www.openfoundry.org/tw/foss-programs/8820-graphviz-

留言