Next: , Previous: Y Axis Element, Up: print-Y-axis

C.2.3 Create a Y Axis Column

The preceding functions provide all the tools needed to construct a function that generates a list of numbered and blank strings to insert as the label for the vertical axis:

     (defun Y-axis-column (height width-of-label)
       "Construct list of Y axis labels and blank strings.
     For HEIGHT of line above base and WIDTH-OF-LABEL."
       (let (Y-axis)
         (while (> height 1)
           (if (zerop (% height Y-axis-label-spacing))
               ;; Insert label.
               (setq Y-axis
                      (Y-axis-element height width-of-label)
             ;; Else, insert blanks.
             (setq Y-axis
                    (make-string width-of-label ? )
           (setq height (1- height)))
         ;; Insert base line.
         (setq Y-axis
               (cons (Y-axis-element 1 width-of-label) Y-axis))
         (nreverse Y-axis)))

In this function, we start with the value of height and repetitively subtract one from its value. After each subtraction, we test to see whether the value is an integral multiple of the Y-axis-label-spacing. If it is, we construct a numbered label using the Y-axis-element function; if not, we construct a blank label using the make-string function. The base line consists of the number one followed by a tic mark.