You are here

AN EFFICIENT ALGORITHM FOR AUTOMATIC SCALING OF AXES

Author(s): 

Timothy Eckert

Note: This article was scanned using OCR from the 1985 Summer CCCE Newsletter. Please contact us if you identify any OCR errors.

Often data generated by laboratory experiments are more easily analyzed when plotted on a graph. In fact, plotting programs are commonly included in computer programs which process data. A necessary part of such programs is the scaling of the axes to provide convenient minima, maxima and step sizes. Some. plotting programs require the user to manually provide the desired minima, maxima and step sizes for the axes, a bothersome task. Other programs automatically scale axes, but either use the largest and smallest coordinates of the data points for the maxima and minima or else always set the minimum at zero. The former technique leads to axes scaled with awkward numbers, while the latter precludes graphing data points with negative coordinates. Moreover even if all the points have positive coordinates but are clustered relatively far from zero, an axis minimum at zero prevents differentiation of the points.

 
The algorithm in my program, SCALING, automatically sets the minima and maxima of the axes at positive or negative values not only to accomodate points with negative coordinates but also to allow greater distinction among points clustered far from zero. To demonstrate the versatility of this program the table beiow shows the scaling output for six types of data ranges (for simplicity, in one dimension only).
SCALING is written in BASIC and is listed below. Its algorithm is not designed to stand alone, but instead to be readily incorporated into the user's own plotting program. In its present form it receives the input of the data minimum and maximum and outputs the appropriate axis minimum, maximum and step size.
 
Of course no algorithm can provide ideal, automatic scaling for all purposes. For example, if one wants to extrapolate a line far from the data points, perhaps to locate a distant axis intercept, this program which focuses on data points fails. An option for manual scaling axes should always accompany any algorithm for automatic scaling.
*Chemistry Department
Fredonia State University College
Fredonia, NY 14063
Date: 
06/04/85 to 06/07/85