MyNixOS website logo
Description

Text Based Plots.

Provides functions to produce rudimentary ascii graphics directly in the terminal window. Provides a basic plotting function (and equivalents of curve, density, acf and barplot) as well as boxplot and image functions.

txtplot

Text based plots in R.

Basic plotting function

require(stats)
txtplot(cars[,1], cars[,2])
    +----+------------+------------+-----------+------------+--+
120 +                                                     *    +
    |                                                          |
100 +                                                          +
    |                                                     * *  |
 80 +                           *         *                    +
    |                                        *       *    *    |
 60 +                           *              *               +
    |                              *    * *    *       *       |
 40 +                         *      *  * *  *                 +
    |                 *       * *    *  *    * *               |
 20 +         *       *  * *  * *  *                           +
    |            *    *  * *                                   |
    |  *      *    *                                           |
  0 +----+------------+------------+-----------+------------+--+
         5           10           15          20           25   

Can include axis labels when desired

txtplot(cars[,1], cars[,2], xlab = "speed", ylab = "distance")
      +----+-----------+------------+-----------+-----------+--+
  120 +                                                   *    +
      |                                                        |
d 100 +                                                   *    +
i     |                                    *                *  |
s  80 +                          *         *                   +
t     |                                       * *    *    *    |
a  60 +                          *  *      *    *      *       +
n     |                        *         * *  * *              |
c  40 +                *       * *    *  *    * *              +
e     |         *      *  * *  * *  *                          |
   20 +           *    *  * *       *                          +
      |  *      *    *                                         |
    0 +----+-----------+------------+-----------+-----------+--+
           5          10           15          20          25   
                                speed                           

Text based density plot

txtdensity(rnorm(500))
0.4 +-----------+--------------+-------------+--------------+--+
    |                       ****                               |
    |                      **   **                             |
    |                     **     **                            |
0.3 +                   ***       ****                         +
    |                 ***            **                        |
    |                **               **                       |
0.2 +               **                 **                      +
    |               *                   *                      |
    |              *                    **                     |
0.1 +            **                      ***                   +
    |           **                         ****                |
    |         ***                             ***              |
  0 +  ********                                 *************  +
    +-----------+--------------+-------------+--------------+--+
               -2              0             2              4   

Text based plotting of functions

txtcurve(x/(x+1), 0, 4, xlab = "Emax model")
    +--+------------+------------+-------------+------------+--+
0.8 +                                        ****************  +
    |                              ***********                 |
    |                       *******                            |
0.6 +                 ******                                   +
    |              ****                                        |
    |           ***                                            |
0.4 +         **                                               +
    |       **                                                 |
0.2 +     **                                                   +
    |    **                                                    |
    |   *                                                      |
  0 +  *                                                       +
    +--+------------+------------+-------------+------------+--+
       0            1            2             3            4   
                             Emax model                         

Text based acf

txtacf(rnorm(100))
     +--+------------+------------+------------+------------+--+
   1 +  *                                                      +
     |  *                                                      |
 0.8 +  *                                                      +
     |  *                                                      |
 0.6 +  *                                                      +
     |  *                                                      |
 0.4 +  *                                                      +
     |  *                                                      |
 0.2 +  *    *  *                                              +
     |  *    *  *                                   *     *    |
   0 +  * *  *  * *  * *  *  * *  *  * *  * *  *  * *  *  * *  +
     |            *  *    *          * *  * *  *  *            |
-0.2 +            *       *            *                       +
     +--+------------+------------+------------+------------+--+
        0            5           10           15           20   

Text based barchart

x <- factor(c("orange", "orange", "red", "green", "green", "red",
             "yellow", "purple", "purple", "orange"))
txtbarchart(x)
   +--+------------+-------------+-------------+------------+--+
30 +               *                                           +
   |               *                                           |
25 +               *                                           +
   |               *                                           |
20 +  *            *             *             *               +
   |  *            *             *             *               |
15 +  *            *             *             *               +
10 +  *            *             *             *            *  +
   |  *            *             *             *            *  |
 5 +  *            *             *             *            *  +
   |  *            *             *             *            *  |
 0 +  *            *             *             *            *  +
   +--+------------+-------------+-------------+------------+--+
      1            2             3             4            5   
Legend: 1=green, 2=orange, 3=purple, 4=red, 5=yellow

Text based boxplots

rand1 <- rnorm(100, 1, 2)
rand2 <- rnorm(50, 2, 2)
rand3 <- rnorm(50, 2, 5)
txtboxplot(rand1)
  -4        -2         0          2         4         6         
 |-+---------+---------+----------+---------+---------+--------|
                      +------+--------+                         
    ------------------|      |        |--------------------     
                      +------+--------+                         
txtboxplot(rand1, rand2, rand3)
          -5               0               5              10    
 |---------+---------------+---------------+---------------+---|
                          +---+-----+                           
1              -----------|   |     |-------------              
                          +---+-----+                           
                               +--+-----+                       
2                       -------|  |     |-----------            
                               +--+-----+                       
                        +--------+-----+                        
3   --------------------|        |     |-------------------     
                        +--------+-----+                        
Legend: 1=rand1, 2=rand2, 3=rand3

Text based image plots (contributed by Ivan Krylov)

txtimage(datasets::volcano, legend = FALSE)
01111111111111111111111111111111111111111111000010000000000000000000000000000000
11111111111111111111111111222211111111111111111111100000000000000000000000000000
11111111111111111222333333333332222211111111111111111111000000000000000000000000
11111111122222223344444445544444332222222222111111111100000000000000000000000000
11111112222333444555566666666555443333222222222211111111110000000000000000000000
11111112223344555667777888877766655443333222222222111111111110000000000000000000
11112223334445566778888888888877665444333333333222222222222111100000000000000000
11122334445566677889888888888887665544433333333333334444332222111100000000000000
11223444555677788999888877778777666555444444444444444444443322211111000000000000
12233445566778899999877766666777766665554444444444444444433332221111111000000000
12233445667788999999877665555667777766665555555555444444433332222211111110000000
11233455667788999999876665555667777777666666665555544444433333222222211111110000
11223445667788899999877666666677788887766666666655554444444333332222221111111100
11222334566778899999988777777778888887777777776665555555444443333322222111111110
11122233456677889999998888888888888887777777777666555555555554433332221111111100
01112223455677888899999888888887777777766677777666655555555555444333221111000000
00111223345667777888888888877766666666666666666666555555555555544432211000000000
01111122334566666777777777776655555555555555555555555555555555544332111000000000
00111112223344555566676666665555554444444444444444445555555555444322111110000000
00011111122333344445566665555444443333333333344444444444444444433332211110000000
00000111112222333344455555544433332222223333333333333333333333333322111110000000
00001111111222233334444444443332222222222222222222222222222233322221111100000000
00011111111122223333444444333222222212222222222222222222222222222211111000000000
00011111111122222333333333222211111111111122222222221122222222222211100000000000
00001111111112222222233322222111111111111111122221111111222222222111100000000000
## this works if your terminal supports shade/block characters
txtimage(datasets::volcano, alphabet = " \u2591\u2592\u2593\u2588", legend = TRUE)
                                                                                
                          ░░░░                                                  
                 ░░░░░░░░░░░░░░░░░░░                                            
         ░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░                                    
       ░░░░░░░▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒░░░░░░░░░░░░░░                                
       ░░░░░▒▒▒▒▒▓▓▓▓▓▓████▓▓▓▓▓▓▒▒▒▒░░░░░░░░░░░░░                              
    ░░░░░░▒▒▒▒▒▓▓▓▓███████████▓▓▓▓▒▒▒▒░░░░░░░░░░░░░░░░░░░░░                     
   ░░░░▒▒▒▒▒▓▓▓▓▓██████████████▓▓▓▒▒▒▒▒░░░░░░░░░░░░░▒▒▒▒░░░░░░                  
  ░░░▒▒▒▒▒▒▓▓▓▓█████████▓▓▓▓█▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░                 
 ░░░░▒▒▒▒▓▓▓▓████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░                
 ░░░░▒▒▒▓▓▓▓█████████▓▓▓▓▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░              
  ░░░▒▒▒▓▓▓▓█████████▓▓▓▓▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░           
  ░░░▒▒▒▓▓▓▓█████████▓▓▓▓▓▓▓▓▓▓▓▓████▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░          
  ░░░░░▒▒▓▓▓▓██████████▓▓▓▓▓▓▓▓██████▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░         
   ░░░░░▒▒▓▓▓▓███████████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░          
    ░░░░▒▒▒▓▓▓█████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░          
     ░░░░▒▒▓▓▓▓▓▓██████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░           
      ░░░░▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░            
       ░░░░░▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░            
         ░░░░░░▒▒▒▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒▒░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░           
          ░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░            
           ░░░░░░░░▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░             
            ░░░░░░░░▒▒▒▒▒▒░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░              
            ░░░░░░░░░░░░░░░░░░            ░░░░░░░░░   ░░░░░░░░░░░░              
             ░░░░░░░░░░░░░░░░                ░░░░       ░░░░░░░░░               

 94 ‘ ’ 114 ‘░’ 134 ‘▒’ 154 ‘▓’ 174 ‘█’ 194 
Metadata

Version

1.0-4

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows