Return the labels of a graph of a function.
lw-gt
generate-labels horizontal-p start step range &key print-function decimal-point color x-adjust y-adjust absolute-p => labels
horizontal-p⇩ |
A boolean. |
start⇩ |
A real number. |
step⇩ |
A real number. |
range⇩ |
A positive real number. |
print-function⇩ | nil , or a function of one argument which takes a real and returns a string. |
decimal-point⇩ |
An integer or nil . |
color⇩ |
A color specification in the Color system. |
nil , a number, or one of the keywords :center and :end-align . | |
absolute-p⇩ |
A boolean. |
labels⇩ |
A list of drawing-objects. |
The function generate-labels
returns a list labels of drawing-objects, which are supposed to be the labels of a graph of a function.
generate-labels
generates a list of drawing objects, which draw strings representing numbers and positioned in regular intervals in one dimension and fixed value in the other dimension.
horizontal-p specifies the dimension. When horizontal-p is true, the objects are placed in a row with regular horizontal intervals, otherwise they are spaced in a column with regular vertical intervals.
start determines the lowest value, range determines the range of values, and step determines the distance between neighbouring values. When step is negative, start is on the right (or top) and the values increase from right to left (or top to bottom).
For each value, generate-labels
generates a string. If print-function is a function, it is called with the value and must return the string. Otherwise generate-labels
makes the string using decimal-point and the value as follows:
(format nil "~,vf" decimal-point value)
It then uses make-draw-string to generate a drawing-object, adjusting the position by x-adjust horizontally and y-adjust vertically and using color as the foreground color and make it "absolute mode" depending on absolute-p. It then positions the object (using position-object) at the right place. The default value of x-adjust is :center
if horizontal-p is true, and :end-align
otherwise. The default value of y-adjust is -1 if horizontal-p is true, and :center
otherwise. The default value of color is :black
.
generate-labels
returns a list of drawing-objects, which is a valid "drawing-object-spec".
generate-labels
will typically be used in conjunction with generate-grid-lines.generate-labels
is quite a simple function. If it does not do what you want, you can improve it easily by writing your own version.(position-object (generate-labels ... :y-adjust 0) :bottom-margin grid-height)
To move the column to the right, change x-adjust to nil
and use left-margin.
fit-object
position-object
generate-grid-lines
drawing-object
14.2 Higher level - drawing graphs and bar charts
CAPI User Guide and Reference Manual (Windows version) - 01 Dec 2021 19:34:19