views:

1690

answers:

5

Hi,

I'm looking for a library to draw ASCII graphs (for use in a console) with Python. The graph is quite simple: it's only a flow chart for pipelines.

I saw NetworkX and igraph, but didn't see a way to output to ascii.

Do you have experience in this?

Thanks a lot!

Patrick

EDIT 1: I actually found a library doing what I need, but it's in perl Graph::Easy . I could call the code from python but I don't like the idea too much... still looking for a python solution :)

+1  A: 

It's not directly Python based, but you should take a look into the artist-mode of emacs

You can control emacs from python with pymacs, or you can take a look at the lisp code and draw some inspiration.

wr
This actually does something similar I'm looking for. But I would like to be independent from emacs or any other IDE. And I prefer to not write my own graph drawing library if I it's somehow possible.
Patrick
A: 

Hi

I tried matplotlib (http://matplotlib.sourceforge.net/) and it was good enough to plot different x-y plots. Though I never tried with it, a graph which depicts a flow.

cheers

Andriyev
A: 

When you say 'simple network graph in ascii', do you mean something like this?

.===.   .===.   .===.   .===.
| a |---| b |---| c |---| d |
'==='   '==='   '---'   '==='

I suspect there are probably better ways to display whatever information it is that you have than to try and draw it on the console. If it's just a pipeline, why not just print out:

a-b-c-d

If you're sure this is the route, one thing you could try would be to generate a decent graph using Matplotlib and then post the contents to one of the many image-to-ascii converters you can find on the web.

Jon Cage
The graph may include forks and joins (the pipeline flow can fork and then join again). Therefore a graphical representation of what's going on would be nice.
Patrick
Fundamentally, I think you'd be better served trying to output the data to file and then processing it using another tool like Willi suggested rather than trying to draw on a console. Maybe you could output the dot format required for graphviz and connect the console output to something which watches for the dot sections to draw your graphs?
Jon Cage
Yes, I think I will go for such a solution.
Patrick
+2  A: 

To draw networks, pydot might be a more convenient solution than matplotlib. It is based on graphviz (gallery).

wr
The library looks very nice. But I didn't see a way to export the graphs to ascii/console.
Patrick
+1  A: 

ascii-plotter might do what you want...

David Wolever