Python ASCII Graph Drawing

Question:

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 🙂

Asked By: Patrick

||

Answers:

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.

Answered By: wr.

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.

Answered By: Jon Cage

ascii-plotter might do what you want…

Answered By: David Wolever
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.