基于命令行的Unix ASCII图表/绘图工具

177
有没有好的命令行UNIX制图/图表/绘图工具?我正在寻找能在ASCII图形上绘制xy点的工具。
只是为了澄清,我正在寻找输出ASCII图形(类似ASCII艺术风格)的工具,因此我可以在交互式shell会话中使用它而不需要X。

8
投票关闭,因为工具推荐。 - Ciro Santilli OurBigBook.com
1
还请查看我的答案 - not2qubit
如何在终端中绘制图表 - Trenton McKinney
我对发帖者有点感到遗憾,因为在发布时可能没有什么选择。今天有一些非常好的选项。 - Sridhar Sarnobat
14个回答

5
您应该使用gnuplot,并确保在启动后发出“set term dumb”命令。您还可以提供行和列计数。如果您发出“set term dumb 64 10”然后“plot sin(x)”,则以下是gnuplot的输出:

 
1 ++-----------****-----------+--***-------+------****--++ 0.6 *+ **+ * +** * sin(x)*******++ 0.2 +* * * ** ** * **++ 0 ++* ** * ** * ** *++ -0.4 ++** * ** ** * * *+ -0.8 ++ ** * + * ** + * +** +* -1 ++--****------+-------***---+----------****-----------++ -10 -5 0 5 10

它在79x24上看起来更好(不要在80x24显示器上使用第80列:某些curses实现在最后一列周围的行为不总是良好的)。

我正在使用gnuplot v4,但这也适用于稍旧或更新的版本。


3

termplotlib (我的一个项目)最近变得越来越受欢迎,或许对某些人有所帮助。

import termplotlib as tpl
import numpy

x = numpy.linspace(0, 2 * numpy.pi, 10)
y = numpy.sin(x)

fig = tpl.figure()
fig.plot(x, y, label="data", width=50, height=15)
fig.show()

    1 +---------------------------------------+
  0.8 |    **     **                          |
  0.6 |   *         **           data ******* |
  0.4 | **                                    |
  0.2 |*              **                      |
    0 |                 **                    |
      |                                   *   |
 -0.2 |                   **            **    |
 -0.4 |                     **         *      |
 -0.6 |                              **       |
 -0.8 |                       **** **         |
   -1 +---------------------------------------+
      0     1    2     3     4     5    6     7

2

这是我为eplot编写的补丁,增加了一个-T选项用于终端输出:

--- eplot       2008-07-09 16:50:04.000000000 -0400
+++ eplot+      2017-02-02 13:20:23.551353793 -0500
@@ -172,7 +172,10 @@
                                        com=com+"set terminal postscript color;\n"
                                        @o["DoPDF"]=true

-                               # ---- Specify a custom output file
+                               when /^-T$|^--terminal$/
+                                       com=com+"set terminal dumb;\n"
+
+                                # ---- Specify a custom output file
                                when /^-o$|^--output$/
                                        @o["OutputFileSpecified"]=checkOptArg(xargv,i)
                                        i=i+1

                                    i=i+1

使用此命令,您可以运行 eplot -T 以获取 ASCII 图形结果而不是 gnuplot 窗口。


1
eplot现在已经内置了-d选项。 - Max

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接