The Not Quite Final Version of print-Y-axis
The list constructed by the Y-axis-column function is passed to the print-Y-axis function, which inserts the list as a column.
emacs-lisp
(defun print-Y-axis (height full-Y-label-width)
"Insert Y axis using HEIGHT and FULL-Y-LABEL-WIDTH.
Height must be the maximum height of the graph.
Full width is the width of the highest label element."
;; Value of height and full-Y-label-width
;; are passed by print-graph.emacs-lisp
(let ((start (point)))
(insert-rectangle
(Y-axis-column height full-Y-label-width))
;; Place point ready for inserting graph.
(goto-char start)
;; Move point forward by value of full-Y-label-width
(forward-char full-Y-label-width)))The print-Y-axis uses the insert-rectangle function to insert the Y axis labels created by the Y-axis-column function. In addition, it places point at the correct position for printing the body of the graph.
You can test print-Y-axis:
- Install
Y-axis-label-spacing Y-axis-tic Y-axis-element Y-axis-column print-Y-axis - Copy the following expression:emacs-lisp
(print-Y-axis 12 5) - Switch to the
*scratch*buffer and place the cursor where you want the axis labels to start. - Type M-: (
eval-expression). - Yank the
graph-body-printexpression into the minibuffer with C-y (yank). - Press RET to evaluate the expression.
Emacs will print labels vertically, the top one being ‘10 - ’. (The print-graph function will pass the value of height-of-top-line, which in this case will end up as 15, thereby getting rid of what might appear as a bug.)