本文介绍了Python ASCII图形绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个库来用Python绘制ASCII图(用于控制台)。这个图很简单:它只是流水线的流程图。



我看到了NetworkX和igraph,但没有看到输出为ascii的方式。

>

您有这方面的经验吗?



非常感谢!



Patrick

编辑1:
我实际上找到了一个库,正在做我需要的东西,但它在perl中。我可以从python调用代码,但我不太喜欢这个想法...仍然在寻找一个python解决方案:)

解决方案

当你说'ascii中的简单网络图表'时,你的意思是这样吗?

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

我怀疑可能有更好的方法来显示你所拥有的任何信息,而不是试图在控制台上绘制它。如果它只是一个管道,为什么不直接打印:

  abcd 

如果您确定这是路线,您可以尝试的一件事就是使用,然后将内容发布到。


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

解决方案

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.

这篇关于Python ASCII图形绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:39
查看更多