When we print the vertical axis, we want to insert strings such as
``5 -'` and ``10 - '` every five lines.
Moreover, we want the numbers and dashes to line up, so shorter
numbers must be padded with leading spaces. If some of the strings
use two digit numbers, the strings with single digit numbers must
include a leading blank space before the number.

To figure out the length of the number, the `length`

function is
used. But the `length`

function works only with a string, not with
a number. So the number has to be converted from being a number to
being a string. This is done with the `int-to-string`

function.
For example,

(length (int-to-string 35)) => 2 (length (int-to-string 100)) => 3

In addition, in each label, each number is followed by a string such
as `` - '`, which we will call the `Y-axis-tic`

marker.
This variable is defined with `defvar`

:

(defvar Y-axis-tic " - " "String that follows number in a Y axis label.")

The length of the Y label is the sum of the length of the Y axis tick mark and the length of the number of the top of the graph.

(length (concat (int-to-string height) Y-axis-tic)))

This value will be calculated by the `print-graph`

function in
its varlist as `full-Y-label-width`

and passed on. (Note that we
did not think to include this in the varlist when we first proposed it.)

To make a complete vertical axis label, a tick mark is concatenated
with a number; and the two together may be preceded by one or more
spaces depending on how long the number is. The label consists of
three parts: the (optional) leading spaces, the number, and the tic
mark. The function is passed the value of the number for the specific
row, and the value of the width of the top line, which is calculated
(just once) by `print-graph`

.

(defun Y-axis-element (number full-Y-label-width) "Construct a NUMBERed label element. A numbered element looks like this ` 5 - ', and is padded as needed so all line up with the element for the largest number." (let* ((leading-spaces (- full-Y-label-width (length (concat (int-to-string number) Y-axis-tic))))) (concat (make-string leading-spaces ? ) (int-to-string number) Y-axis-tic)))

The `Y-axis-element`

function concatenates together the leading
spaces, if any; the number, as a string; and the tick mark.

To figure out how many leading spaces the label will need, the function subtracts the actual length of the label--the length of the number plus the length of the tic mark--from the desired label width.

Blank spaces are inserted using the `make-string`

function.
This function takes two arguments: the first tells it how long the
string will be and the second is a symbol for the character to insert,
in a special format. In this case, the format is a question mark
followed by a blank space, like this, ``? '`.
See section `Character Type' in The GNU Emacs Lisp Reference Manual, for a description of the syntax for characters.

The `int-to-string`

function is used in the concatenation
expression, to convert the number to a string that is concatenated
with the leading spaces and the tic mark.

Go to the first, previous, next, last section, table of contents.