31

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

Patrick
  • 809
  • 3
  • 9
  • 21

3 Answers3

3

ascii-plotter might do what you want...

David Wolever
  • 148,955
  • 89
  • 346
  • 502
2

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
  • 36,366
  • 38
  • 137
  • 215
  • 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 May 07 '09 at 13:54
  • 1
    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 May 07 '09 at 15:44
  • Yes, I think I will go for such a solution. – Patrick May 07 '09 at 16:36
1

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.
  • 2,841
  • 1
  • 23
  • 27
  • 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 May 07 '09 at 14:02