Next: Compute a Remainder, Previous: print-Y-axis in Detail, Up: print-Y-axis

The next issue is what height the label should be? Suppose the maximum
height of tallest column of the graph is seven. Should the highest
label on the Y axis be ‘`5 -`’, and should the graph stick up above
the label? Or should the highest label be ‘`7 -`’, and mark the peak
of the graph? Or should the highest label be `10 -`

, which is a
multiple of five, and be higher than the topmost value of the graph?

The latter form is preferred. Most graphs are drawn within rectangles
whose sides are an integral number of steps long—5, 10, 15, and so
on for a step distance of five. But as soon as we decide to use a
step height for the vertical axis, we discover that the simple
expression in the varlist for computing the height is wrong. The
expression is `(apply 'max numbers-list)`

. This returns the
precise height, not the maximum height plus whatever is necessary to
round up to the nearest multiple of five. A more complex expression
is required.

As usual in cases like this, a complex problem becomes simpler if it is divided into several smaller problems.

First, consider the case when the highest value of the graph is an integral multiple of five—when it is 5, 10, 15, or some higher multiple of five. We can use this value as the Y axis height.

A fairly simply way to determine whether a number is a multiple of five is to divide it by five and see if the division results in a remainder. If there is no remainder, the number is a multiple of five. Thus, seven divided by five has a remainder of two, and seven is not an integral multiple of five. Put in slightly different language, more reminiscent of the classroom, five goes into seven once, with a remainder of two. However, five goes into ten twice, with no remainder: ten is an integral multiple of five.