我正在 Python 程序中生成图表,现在我需要将它们可视化。
我使用 Tkinter 作为 GUI 来可视化所有其他数据,并且我希望在内部有一个带有数据图表的小子窗口。
目前,我的数据以 .dot 文件形式表示。 然后我保持 graphviz 打开,它会显示图表。 但这当然不是最理想的。 我需要在 tk 窗口内获取图表。
我考虑过从命令行使用 graphviz,但我总是遇到同样众所周知的错误:
Desktop ibook$ dot -Tpng -O 1.dot
dyld: lazy symbol binding failed: Symbol not found: _pixman_image_create_bits
Referenced from: /usr/local/lib/graphviz/libgvplugin_pango.5.dylib
Expected in: flat namespace
dyld: Symbol not found: _pixman_image_create_bits
Referenced from: /usr/local/lib/graphviz/libgvplugin_pango.5.dylib
Expected in: flat namespace
Trace/BPT trap
该错误似乎在 Graphviz 社区中众所周知:
http://www.graphviz.org/bugs/b1479.html
http://www.graphviz.org/bugs/b1488.html
http://www.graphviz.org/bugs/b1498.html
因此,既然我似乎无法使用命令行实用程序,我想知道是否有人知道绘制点图的直接方法在Python中,不使用命令行,或者做一些会引发相同错误的事情?
我正在 Mac Leopard 上编程,python 2.5.2
I am producing graphs in a Python program, and now I need to visualize them.
I am using Tkinter as GUI to visualize all the other data, and I would like to have a small subwindow inside with the graph of the data.
At the moment I have the data being represented in a .dot file. And then I keep graphviz open, which shows the graph. But this is of course suboptimal. I need to get the graph inside the tk window.
I thought about using graphviz from the command line, but I always run into the same well known bug:
Desktop ibook$ dot -Tpng -O 1.dot
dyld: lazy symbol binding failed: Symbol not found: _pixman_image_create_bits
Referenced from: /usr/local/lib/graphviz/libgvplugin_pango.5.dylib
Expected in: flat namespace
dyld: Symbol not found: _pixman_image_create_bits
Referenced from: /usr/local/lib/graphviz/libgvplugin_pango.5.dylib
Expected in: flat namespace
Trace/BPT trap
The bug seem to be well known in the Graphviz community:
http://www.graphviz.org/bugs/b1479.html
http://www.graphviz.org/bugs/b1488.html
http://www.graphviz.org/bugs/b1498.html
So since it seems that I cannot use the command line utility I was wondering if anyone knew a direct way to draw a dot graph in Python, without using the command line, or doing something that would incur the same error?
I am programming on a Mac Leopard, python 2.5.2
发布评论
评论(2)
我没有 Mac 来测试它,但是 NetworkX 包包含 读取 .dot 文件 和 使用 >matplotlib。 您可以在 Tk 中嵌入 matplotlib 图形(示例 1,示例2)。
I do not have a mac to test it on, but the NetworkX package includes methods to read .dot files and draw graphs using matplotlib. You can embed a matplotlib figure in Tk (example 1, example 2).
快速Google 调出http://code.google.com/p/pydot/。 我还没有尝试过,但看起来很有希望。
Quick Google pulls up http://code.google.com/p/pydot/. I haven't tried it but it looks promising.