R的ASCII绘图函数

Eri*_*own 14 graphics text r data-visualization

为了访问我的服务器,我被迫使用没有X窗口的旧文本终端应用程序.我要做的最好的事情是emacs/ESS.

通常,我希望制作直方图和散点图等基本图,而不必经历将文件传输到带图形显示的计算机的麻烦.

是否有基于文本终端的R图形库?

Gle*_*n_b 25

有很多事情可以做些什么.有stem违约R,有 scat之三绘图功能,但最重要的是,有个包txtplot这确实散点图,箱线图,barplots,密度痕迹,ACFS和图表曲线(如在CRAN curve功能...有点儿).

我偶尔只需要它 - 但如果我试图用纯文本传达一个粗略的想法,我有时需要它,这是一个救生员.

在过去,我写了一小段,在非常快的时间做理货风格的ASCII图形(如横盘条形图或用符号代替数字,这解决了一个问题,我有一个茎和叶的情节)R代码 - 但我没有保留它,因为干主要涵盖那个领域.

当然,'table'工具可以产生ascii输出,并且可以被操作来做一些有趣/有用的semigraphical事物.

ascii可能被用来渲染各种的R类似的方式Sweave对象转换成ASCII码形式-方便的格式化表格等.只是将表格式化为ascii并不是真正的用途,但你可能仍然可以通过一些工作和正确的输出格式来使用它.

txtplot的样本输出:

散点图:

 > with(cars,txtplot(speed,dist))
     +----+-----------+------------+-----------+-----------+--+
 120 +                                                   *    +
     |                                                        |
 100 +                                                        +
     |                                                   * *  |
  80 +                          *         *                   +
     |                                       *      *    *    |
  60 +                          *              *              +
     |                             *    * *    *      *       |
  40 +                        *      *  * *  *                +
     |                *       * *    *  *    * *              |
  20 +         *      *  * *  * *  *                          +
     |           *    *  * *                                  |
     |  *      *    *                                         |
   0 +----+-----------+------------+-----------+-----------+--+
          5          10           15          20          25   
Run Code Online (Sandbox Code Playgroud)

acf情节:

 > txtacf(ldeaths)
      +-+--------------+--------------+--------------+--------+
    1 + *                                                     +
      | *                                                     |
      | *  *                        * *  *                    |
  0.5 + *  *                        * *  *                    +
      | *  * *                   *  * *  * *                  |
      | *  * *                   *  * *  * *                  |
      | *  * *                   *  * *  * *                  |
    0 + *  * *  * *  * *  * *  * *  * *  * *  * *  * *  * *   +
      |           *  * *  * *                   *  * *  * *   |
      |           *  * *  * *                   *  * *  * *   |
      |           *  * *  * *                      * *  * *   |
 -0.5 +              * *  *                        * *  *     +
      |              * *  *                          *        |
      +-+--------------+--------------+--------------+--------+
        0             0.5             1             1.5        
Run Code Online (Sandbox Code Playgroud)

密度跟踪:

 > txtdensity(rnorm(100,m=5,s=.1))
   +------+----------+----------+----------+----------+-------+
   |                           *****                          |
 4 +                          **   ***                        +
   |                         *       ***                      |
   |                        **         ***                    |
 3 +                       **            ***                  +
   |                     ***               **                 |
   |                 *****                   **               |
 2 +               ***                        **              +
   |             ***                           **             |
   |            **                              **            |
 1 +           **                                ***          +
   |         ***                                   ******     |
   |  ********                                          ***   |
   +------+----------+----------+----------+----------+-------+
         4.8        4.9         5         5.1        5.2       
Run Code Online (Sandbox Code Playgroud)

箱形图:

 > vc <- ToothGrowth[,2]=="VC"
 > oj <- ToothGrowth[,2]=="OJ"
 > txtboxplot(ToothGrowth[vc,1],ToothGrowth[oj,1])
       5      10       15       20       25       30      35   
  |----+-------+--------+--------+--------+--------+-------+--|
                  +--------+-----------+                       
 1   -------------|        |           |------------------     
                  +--------+-----------+                       
                         +------------+----+                   
 2          -------------|            |    |---------          
                         +------------+----+                   
 Legend: 1=ToothGrowth[vc, 1], 2=ToothGrowth[oj, 1]
Run Code Online (Sandbox Code Playgroud)

曲线图:

 > txtcurve(sin(pi*x),from=0,to=2)
      +--+-----------+------------+------------+-----------+--+
    1 +          *********                                    +
      |        ***        **                                  |
      |       **            **                                |
  0.5 +     **               **                               +
      |    **                  **                             |
      |   *                     **                            |
    0 +  *                       **                        *  +
      |                            *                      *   |
      |                             **                  **    |
 -0.5 +                              ***               **     +
      |                                **            **       |
      |                                  **        ***        |
   -1 +                                    *********          +
      +--+-----------+------------+------------+-----------+--+
         0          0.5           1           1.5          2   
Run Code Online (Sandbox Code Playgroud)

条形图:

 > txtbarchart(as.factor(res),pch="|")
    +--+------------+------------+------------+------------+--+
 50 +  |                                                      +
    |  |                                                      |
 40 +  |                                                      +
    |  |                                                      |
 30 +  |                         |                            +
    |  |                         |                            |
    |  |                         |                            |
 20 +  |                         |                         |  +
    |  |                         |                         |  |
 10 +  |                         |                         |  +
    |  |                         |                         |  |
  0 +  |                         |                         |  +
    +--+------------+------------+------------+------------+--+
       1           1.5           2           2.5           3   
 Legend: 1=A, 2=B, 3=C
Run Code Online (Sandbox Code Playgroud)

stem从默认的R图形添加功能:

> stem(log(islands,10))

  The decimal point is at the |

  1 | 1111112222233444
  1 | 5555556666667899999
  2 | 3344
  2 | 59
  3 | 
  3 | 5678
  4 | 012
Run Code Online (Sandbox Code Playgroud)

你有很多报道.

  • 以下是 ASCII 世界地图绘图的一些代码:https://gist.github.com/nevrome/d071bc9d636a2f32991f8d984d6f25ef (2认同)