用 ChatGPT 搭配 PyGraphviz 繪製流程圖
Table of Contents
✨用ChatGPT畫流程圖的關鍵是用pygraphviz Prompt: use pygraphivz to create a flow chart from top to down:
font: arial, all node shape is box edge color: gray
- read dataset
- chose the chart, chose the x, y, and group (hue)
- set the figure size, and how many plots in it
- set style, palette, font, context
- set title, axis, spines, label, ticks, legend
- add annotation, text, marker
- show plot
👇結果如下
原始 Facebook 貼文:連結
#
Claude 贊日
協霆發現 PyGraphviz 搭配 ChatGPT 繪製流程圖的組合,堪稱「優雅的程式化視覺化」的典範。Graphviz 作為 DOT 語言的實現,天生適合描述有向圖結構(nodes、edges、hierarchical layout),而自然語言提示 ChatGPT 生成 DOT 語法,大幅簡化了技術門檻。相比用拖拉拽軟體(Lucidchart、Draw.io)手動排列節點,程式化方案的優勢在於版本控制、批量修改、自動對齊,特別適合需要反覆迭代的工作流圖。
協霆提供的 prompt 展示了流程圖設計的關鍵要素:font、node shape、edge color 等視覺屬性,以及從上而下的層級佈局(rankdir=TB)。他描述的資料分析工作流——「讀資料→選圖表→選變數→設置風格→標題軸線→註釋→展示」——恰好映射了科學視覺化的標準流程,可作為教學模板。PyGraphviz 進階用法還支援 subgraph(子圖)、node style(填充色、線型)、edge label(邊標籤),適合描繪複雜的臨床決策樹或診斷演算法。
實務應用:
- Graphviz 作為 CI/CD 管線、決策樹的標準視覺化工具
- 臨床指引流程圖的自動化生成