GSCALE Call

CALL GSCALE (scale, x, nincr <*>, nicenum <*>, fixed-end ) ;

The GSCALE subroutine computes a suitable scale and tick values for labeling axes.

The required arguments to the GSCALE subroutine are as follows:

scale

is a returned vector that contains the scaled minimum data value, the scaled maximum data value, and a grid increment.

x

is a numeric matrix or literal.

nincr

is the number of intervals desired.

The optional arguments to the GSCALE subroutine are as follows:

nicenum

is numeric and provides up to 10 numbers to use for scaling. By default, nicenum is the vector {1,2,2.5,5}.

fixed-end

is a character argument that specifies which end of the scale is held fixed. The default is 'X'.

The GSCALE subroutine obtains simple (round) numbers with uniform grid interval sizes to use in scaling a linear axis. The GSCALE subroutine implements Algorithm 463 (Lewart, 1973) of the Collected Algorithms from the Association for Computing Machinery (ACM). The scale values are integer multiples of the interval size. They are returned in the first argument, a vector with three elements. The first element is the scaled minimum data value. The second element is the scaled maximum data value. The third element is the grid increment.

The required input parameters are x, a matrix of data values, and nincr, the number of intervals desired. If nincr is positive, the scaled range includes approximately nincr intervals. If nincr is negative, the scaled range includes exactly ABS(nincr) intervals. The nincr parameter cannot be zero.

The nicenum and fixed-end arguments are optional. The nicenum argument provides up to 10 numbers, all between 1 and 10 (inclusive of the endpoints), to be used for scaling. The default for nicenum is 1, 2, 2.5, and 5. The linear scale with this set of numbers is a scale with an interval size that is the product of an integer power of 10 and 1, 2, 2.5, or 5. Changing these numbers alters the rounding of the scaled values.

For fixed-end, 'U' fixes the upper end; 'L' fixes the lower end; 'X' allows both ends to vary from the data values. The default is 'X'. An example that uses the GSCALE subroutine follows:

x = normal( j(100,1) );   /* generate standard normal data */
call gscale(scale, x, 5); /* ask for about 5 intervals */
ticks = do(scale[1], scale[2], scale[3]);
print scale, ticks;

Figure 24.147: Tick Marks for Standard Normal Data

scale
-3
3
1

ticks
-3 -2 -1 0 1 2 3