Next: , Previous: , Up: Graphing   [Contents][Index]


5.9.1 Character Plotting

(require 'charplot)

Variable: charplot:dimensions

A list of the maximum height (number of lines) and maximum width (number of columns) for the graph, its scales, and labels.

The default value for charplot:dimensions is the output-port-height and output-port-width of current-output-port.

Procedure: plot coords x-label y-label

coords is a list or vector of coordinates, lists of x and y coordinates. x-label and y-label are strings with which to label the x and y axes.

Example:

(require 'charplot)
(set! charplot:dimensions '(20 55))

(define (make-points n)
  (if (zero? n)
      '()
      (cons (list (/ n 6) (sin (/ n 6))) (make-points (1- n)))))

(plot (make-points 40) "x" "Sin(x)")
-|
  Sin(x)   _________________________________________
         1|-       ****                             |
          |      **    **                           |
      0.75|-    *        *                          |
          |    *          *                         |
       0.5|-  *            *                        |
          |  *                                     *|
      0.25|-                *                     * |
          | *                *                      |
         0|-------------------*------------------*--|
          |                                     *   |
     -0.25|-                   *               *    |
          |                     *             *     |
      -0.5|-                     *                  |
          |                       *          *      |
     -0.75|-                       *        *       |
          |                         **    **        |
        -1|-                          ****          |
          |:_____._____:_____._____:_____._____:____|
     x                 2           4           6
Procedure: plot func x1 x2
Procedure: plot func x1 x2 npts

Plots the function of one argument func over the range x1 to x2. If the optional integer argument npts is supplied, it specifies the number of points to evaluate func at.

(plot sin 0 (* 2 pi))
-|
           _________________________________________
         1|-:       ****                            |
          | :     **    **                          |
      0.75|-:    *        *                         |
          | :   *          *                        |
       0.5|-:  **          **                       |
          | : *             *                       |
      0.25|-:**              **                     |
          | :*                *                     |
         0|-*------------------*--------------------|
          | :                  *                 *  |
     -0.25|-:                   **              **  |
          | :                    *             *    |
      -0.5|-:                     *           **    |
          | :                      *          *     |
     -0.75|-:                       *       **      |
          | :                        **    **       |
        -1|-:                          ****         |
          |_:_____._____:_____._____:_____._____:___|
            0           2           4           6
Procedure: histograph data label

Creates and displays a histogram of the numerical values contained in vector or list data

(require 'random-inexact)
(histograph (do ((idx 99 (+ -1 idx))
                 (lst '() (cons (* .02 (random:normal)) lst)))
                ((negative? idx) lst))
            "normal")
-|
           _________________________________________
         8|-                :    I                  |
          |                 :    I                  |
         7|-           I  I :    I                  |
          |            I  I :    I                  |
         6|-          III I :I   I                  |
          |           III I :I   I                  |
         5|-          IIIIIIIIII I                  |
          |           IIIIIIIIII I                  |
         4|-          IIIIIIIIIIII                  |
          |           IIIIIIIIIIII                  |
         3|-I    I I  IIIIIIIIIIII  II     I        |
          | I    I I  IIIIIIIIIIII  II     I        |
         2|-I    I I IIIIIIIIIIIIIIIII     I        |
          | I    I I IIIIIIIIIIIIIIIII     I        |
         1|-II I I IIIIIIIIIIIIIIIIIIIII   I I I    |
          | II I I IIIIIIIIIIIIIIIIIIIII   I I I    |
         0|-IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII----|
          |__.____:____.____:____.____:____.____:___|
  normal        -0.025      0       0.025      0.05

Next: , Previous: , Up: Graphing   [Contents][Index]