This HTML automatically generated with rman for NEMO
Table of Contents

Name

xaxis, yaxis, axvar, xaxvar, yaxvar - routines to draw various kinds of axes

Synopsis


#include <axis.h>
void xaxis(x0, y0, l, tick, nticks, trans, label)
void yaxis(x0, y0, l, tick, nticks, trans, label)
real x0, y0, l, tick[];
int ntick;
axis_proc trans;
string label;
void axvar(sznum, szlab, scale)
real sznum, szlab, scale;
void xaxvar(ndig, tikup, tikdn, numdn, labdn)
void yaxvar(ndig, tikup, tikdn, numdn, labdn)
int ndig;
real tikup, tikdn, numdn, labdn;
extern real trans(/* real r */);

Description

The axis(3NEMO) routines provide a simple but general interface to the yapp(3NEMO) routines to draw and label X and Y-axes. Some helper routines exist with which the axis control variables (such as size and location of tick marks/values and labels - see below) can be changed, though at startup they are all given reasonable values.

With the routines xaxis and yaxis a X- and Y-axis can be drawn. Axes can have both tickmarks and labels (in which case tick values are also drawn), though the programmer can select any of them to be absent. (x0,y0) is the lower/left edge of the x/y-axis, and l it’s length. nticks controls the tick marks along the axis. If positive, it is the length of the array tick containing all of the tick values; if negative, it’s absolute value gives the number of ticks (excluding the edges, where ticks are never drawn), and tick[0],tick[1] give the minimum and maximum value along the axis. trans is a (real-valued) function (of a single real-valued argument) that converts world coordinates to cm (the yapp units). label is a text string, that is used as a centered label along the axis. It can be the NULL string, in which case no label and no tick values are plotted.

axvar provides global control over both the X and Y-axis. sznum is the size of the tick values (in cm). szlab is the size of the text label (in cm). scale rescales all (6) real axis variables by multiplying it with the old values. Any of these three parameters can be negative, in which case no action is undertaken. Defaults are described below.

xaxvar and yaxvar provide control over the X and Y axis separately. ndig controls the number of significant digits after the decimal point, with which tick values are printed (though any trailing zeroes are always deleted). tikup and tikdn are the values of the length of the tick up and down from the axis (the ’down’ is usually 0.0, i.e. ticks are normally not drawn outwards from an axis). numdn is the distance from the axis where the tick values are drawn. labdn is the distance from the axis where the label string is drawn (default: 1.0cm for both X- and Y-axis). Again, any variable can be given negative, in which case no action is undertaken.

Bugs

The real-valued axis control variables ( tikup, tikdn, numdn, sznum, labdn, szlab for both the X-axis and Y-axis) are all in cm, with the usual yapp(3NEMO) convention that the viewport is 20 by 20 cm. This confuses some english speaking nations.

There is no automatic tick value scaling.

Examples

The following code will draw a linear X axis, from -4 to 4, with major and minor tickmarks; only the major tickmarks are labeled.
        real xrange[2] = {-4, 4};
        axis_proc xtrans();
        ..
        xaxvar(-1,0.2,-1,-1,-1);    /* redefine big ticks */
        xaxis(2, 2, 16, xrange, -7, xtrans, "My-X-label");
        xaxvar(-1,0.1,-1,-1,-1);    /* set small ticks */
        xaxis(2, 2, 16, xrange,-31, xtrans, NULL);
        xaxvar(-1,0.2,-1,-1,-1);    /* and reset */
        ..
        real xtrans(real x)
        {
            return 2 + 16*(x-xrange[0])/(xrange[1]-xrange[0]);
        }

Axis Control Variables


Variable    X    Y    Comments
ndig    2    2    number of digits after decimal point
tikup    0.2    0.2    tick-lenght upward from axis
tikdn    0.0    0.0    tick-lenght downward from axis
numdn    0.4    0.3    distance from axis where tick values drawn
sznum    0.32    0.32    size of tick values
labdn    1.0    1.0    distance from axis where axis label drawn
szlab    0.32    0.32    size of axis labels

See Also

yapp(3NEMO)

Author

Joshua Barnes, Peter Teuben

Update History


xx-xxx-86    Code written              JEB
25-apr-92    Document written    PJT
xx-xxx-xx    Added automatic tick value scaling option    PJT
16-feb-97    axis_proc for SINGLEPREC                      pjt


Table of Contents