views:

670

answers:

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  A: 

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).

Autoplectic
Very interesting, thank you. Defeinitly a path worth investigating more. I will do it, and then see if it solves the issue. The main problem is that the graph visualization generated must make sense. In dot I eventually managed to make it appear well. I will need to see how to do it in netoworkx. And yes, I do use matplotlib
Pietro Speroni
+1  A: 

Quick Google pulls up http://code.google.com/p/pydot/. I haven't tried it but it looks promising.

Joe Beda