您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python中的树图

Python中的树图

有graphviz- http://www.graphviz.org/。它使用“ DOT”语言绘制图形。您既可以自己生成DOT代码,也可以使用pydot-https://code.google.com/p/pydot/。您还可以使用networkx-http: //networkx.lanl.gov/tutorial/tutorial.html#drawing-graphs ,它可以很容易地绘制到graphviz或matplotlib。

networkx + matplotlib + graphviz为您提供最大的灵活性和功能,但是您需要安装很多东西。

如果需要快速解决方案,请尝试:

安装Graphviz。

open('hello.dot','w').write("digraph G {Hello->World}")
import subprocess
subprocess.call(["path/to/dot.exe","-Tpng","hello.dot","-o","graph1.png"]) 
# I think this is right - try it form the command line to debug

然后安装pydot,因为pydot已经为您完成了这项工作。然后,您可以使用networkx来“驱动” pydot。

python 2022/1/1 18:34:10 有484人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶