generate-labels horizontal-p start step range &key print-function decimal-point color x-adjust y-adjust absolute-p => labels
A boolean.
A real number.
A real number.
A positive real number.
nil
, or a function of one argument which takes a real and returns a string.
An integer or nil
.
A color specification in the Color system.
nil
, a number, or one of the keywords :center
and :end-align
.
A boolean.
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, the start value is on the right (top) and the values increase from right to left (top to bottom).
For each value, generate-labels
generates a string. If
print-function
is a function, it is called with the value and needs to return the string. Otherwise generate-labels
uses
(format nil "~,vf"
decimal-point
value)
to generate the string. 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
Higher level - drawing graphs and bar charts
CAPI User Guide and Reference Manual (Unix version) - 25 Feb 2015