www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_284.html   search  
 
Buy the book!


Programming in Emacs Lisp

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

C.4.1 Testing print-graph

We can test the print-graph function with a short list of numbers:

  1. Install the final versions of Y-axis-column, graph-body-print, and print-graph (in addition to the rest of the code.)

  2. Copy the following expression:

     
    (print-graph '(3 2 5 6 7 5 3 4 6 4 3 2 1))
    

  3. Switch to the `*scratch*' buffer and place the cursor where you want the axis labels to start.

  4. Type M-: (eval-expression).

  5. Yank the test expression into the minibuffer with C-y (yank).

  6. Press RET to evaluate the expression.

Emacs will print a graph that looks like this:

 
10 -


         *
        **   *
 5 -   ****  *
       **** ***
     * *********
     ************
 1 - *************

     |   |    |    |
     1   5   10   15

On the other hand, if you pass print-graph a vertical-step value of 2, by evaluating this expression:

 
(print-graph '(3 2 5 6 7 5 3 4 6 4 3 2 1) 2)

The graph looks like this:

 
20 -


         *
        **   *
10 -   ****  *
       **** ***
     * *********
     ************
 2 - *************

     |   |    |    |
     1   5   10   15

(A question: is the `2' on the bottom of the vertical axis a bug or a feature? If you think it is a bug, and should be a `1' instead, (or even a `0'), you can modify the sources.)


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003