python流程图-python中的图表渲染(流程图可视化)

1586010002-jmsa.png

to visualize a sequence of nodes connected by edges encoded in python.

looking for a python library to visualize such graph data.

either a library written in python or python bindings, is ok

(i am aware of Visustin, but looking for alternatives)

解决方案

Graphviz is the best option in my opinion.

Graphviz is the premiere graph rendering/layout library; it's mature, stable, open-source, and free of charge. It is not a dedicated flowchart or diagramming package, but its core use case--i.e., efficient and aesthetic rendering of objects comprised of nodes and edges, obviously subsumes flowchart drawing--particularly because its api allows the user to set various constraints on the layout to encourage rendering in the various formats--eg, you can require all nodes of the same level (same number of parents from the root) to be rendered in a single center-aligned row.

Graphviz is not a python library (it's written in C); however there are high quality python bindings available.

The python-Graphviz library I am most familar with is pygraphviz, which is excellent.

The other two are pydot and yapgvb. I have used both of these at least a few times. Each is smaller than pygraphviz (which might be an advantage depending on your use case); in addition neither is documented as well as pygraphviz.

Fortunately, all three of these python libraries are thin wrappers over Graphviz, so none conceal the lightweight, elegant Graphviz syntax (the dot language).

bPkog.png

Here's the code (in graphviz' dot language) I used to create the small "flowchart" below:

digraph {

node [ fill=cornflowerblue,

fontcolor=white,

shape=diamond,

style=filled];

Step1 [ color=darkgoldenrod2,

fontcolor=navy,

label=start,

shape=box];

Step2;

Step3a [ style=filled,

fillcolor=grey80,

color=grey80,

shape=circle,

fontcolor=navy];

Step1 -> Step2;

Step1 -> Step2a;

Step2a -> Step3a;

Step3;

Step3a -> Step3;

Step3a -> Step2b;

Step2 -> Step2b;

Step2b -> Step3;

End [ shape=rectangle,

color=darkgoldenrod2,

fontcolor=navy];

Step3 -> End [label=193];

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值