Table of contents


NAME

graph - 2-D graphics program from <PLOT79> package

SYNOPSIS

graph* [ * = device library letter]

DESCRIPTION

Graph is a FORTRAN program which is supplied with the <PLOT79> scientific line graphics package, which creates plots of one or more sets of two dimensional data, either as curves (using either linear or logarithmic axes) or histograms. A rather large number of options are available, making this quite a powerful program for general graphing applications. Defaults are provided for all variables, so that the simplest use requires only data points and three titles (any of which may be blank). The plottable output is sent to a file named by the CRT environment variable, or to CRT.num if CRT is undefined (num is a number which begins at 1 and is incremented appropriately to prevent files being overwritten).

Graph also serves as an example of a driver program for the lower-level routines of <PLOT79>. Input is taken from inputfile, a run-time log is written to the standard output, and graphical output is placed in the file defined by the environment variable CRT, which should be set with the setenv command. In the absence of a CRT value, the system places output in a file named CRT, with an appended version number. The device for which output is intended depends upon which device library was linked to the program at the time of installation (Tektronix 4014 for the default Sun installation).

More information on the use of graph, including the format of inputfile, appears in the PLOT79 section of the rdinfo program, and in the section entitled "DETAILED INSTRUCTIONS" below.


FILES

/usr/local/plot79/graph.f
source code
/usr/local/plot79/graph*
executable files
/usr/local/plot79/define
various environment definitions, an appropriate subset of which should be placed in the user's .cshrc or .profile file

SEE ALSO

document (1L), drawit(1L), graph3t(1L), lptops(1L), pfort(1L), piechtt(1L), plot79-intro(1L), plot79(1L), pluto(1L), pretty(1L), rdinfo(1L), sf3(1L), slides(1L), tekalw(1L), tkvecs(1L), tmacro(1L), world(1L)

AUTHOR

Nelson H. F. Beebe, Ph.D.

Center for Scientific Computing

South Physics Building

University of Utah

Salt Lake City, UT 84112

Tel: (801) 581-5254

(Manual page by R. P. C. Rodgers, Computer Applications in Laboratory Medicine Project, UCSF, San Francisco, CA 94143).


DETAILED INSTRUCTIONS

Input is free format and keyword-driven. Here is an example of an input file:

 $DATA X(1,1)=1,2,3,4,5,6,7,8,9,10,
       Y(1,1)=7,2,4,3,3,6,0,9,1,5,
       X(1,2)=0,2,3,4,5,6,7,8,9,10,
       Y(1,2)=5,1,9,0,6,3,3,4,2,7,
       NUMINT(1)=500, NUMINT(2)=1500,
       NU(1)=1,1,
       PEN(1)=1,2,
       MARK(1)=20,17,
       LSTYLE(1)=1,2,
 $END
Sample XY Plot
X axis
Y axis

There are two sections: the first is NAMELIST-like and contains (between $DATA and $END) the data and various commands defining the style of the plot. This is followed by three 120-character title lines for the main title of the graph, the X-axis title, and the Y-axis title.

The file may contain multiple sets of $DATA...$END and label lines; one plot will be generated for each set. The maximum number of curves and data points allowed depends upon array dimensions set in the <PLOT79> routine GRFGG.

There follow three sections, dealing with: plot labels, plot formatting commands, and data value storage.


PLOT LABELS

The last non-blank character in each title will be used to determine the title length, and the resulting string will be centered on the plot. Lower-case letters may be used in titles, if they are available. Otherwise, they can be obtained by using the case switch characters, "<" and ">" (left and right angle brackets), which convert following letters to upper and lower case respectively. A double appearance of a switch character suppresses its interpretation as a case switch, and causes a single representation of the character to be displayed in the plotted string. Multiple line titles can be obtained by separating the line strings by the two-character sequence $N or $n. Thus, if the graph title line supplied is:

Label 1$NLabel 2$NLabel 3

then the graph title will be three centered lines.

When multiple-line titles are requested, it will usually be necessary to reduce the horizontal and vertical extent of the plot through the options HSCALE and VSCALE in order to make the margins sufficiently large for the title text.


PLOT FORMATTING COMMANDS

There is a detailed description of each command following the list by category.

List of Commands by Category

Axis control
DXSUB, DYSUB, LOGX, LOGY, MODEX, MODEY, NXSUB, NYSUB, TICKX, TICKY, XAXIS, XMIN, XMAX, YAXIS, YMIN, YMAX, XFALLS, YFALLS
Curve display transformations
AVRAGE(*), DERIV(*), INTGRT(*)
Curve styles
LSTYLE(*), LWIDTH(*), PEN(*)
Data point transformations
XFACT(*), YFACT(*), XSHIFT(*), YSHIFT(*)
Error bars
DFXERR, DFYERR, XMINUS(*), XPLUS(*), YMINUS(*), YPLUS(*)
Graph size and aspect ratio
SIZEIN, SIZECM, HSCALE, VSCALE
Histograms
BWIDTH(*), FILLIN(*), HMASK(*), HISTGM(*), YBASE(*), YSTACK(*)
Interpolation
CHKDUP, NUMINT(*), SIGMA(*)
Labelling
IDFONT, PENDIA, title lines
Listing control
LISTXY
Markers
MARK(*), NU(*), SIZEMK
Number of curves
KX, KY
Raw data points
X(*,*), Y(*,*), N(*)

Mandatory Commands (Data)

X(I,K)
The X value of point I in curve K. X values must be in ascending order if integration, averaging, or differentiation of the input curves are requested. Interpolation can be done for arbitrary curves in the plane, including closed curves (signalled by the first point being the same as the last point). For histogram plots, bar I in curve K has width BWIDTH(K), center at X(I,K), bottom at YBASE(K), and top at Y(I,K).
Y(I,K)
The Y value of point I in curve K.

Optional Commands (Defaults Often Adequate)

AVRAGE(K)
.TRUE. - Plot accumulated average of curve K. This is drawn with the same line type as the curve itself, but no data point symbols are marked.

.FALSE. - No averages plotted (default).
BOX
.TRUE. - Draw a box around the outer plot frame (default).

.FALSE. - Omit the outer frame box.
BWIDTH(K)
The width of bars for histogram K.
CHKDUP
.TRUE. - Eliminate adjacent duplicate points in each curve. This is only useful when interpolation is being done.

.FALSE. - No duplicate point check (default).
DERIV(K)
.TRUE. - Plot derivative of interpolated curve K.

.FALSE. - Plot curve K itself (default). This option has no effect unless NUMINT(K) .NE. 0. When derivative plotting is requested, it will be necessary to explicitly supply YMIN, DYSUB, and YMAX, since these will in general be unrelated to the input values Y(*,K) from which the default YMIN, DYSUB, and YMAX are determined.
DFXERR
Fraction of window width to be used for terminating horizontal bars on vertical error bars (default 0.02).
DFYERR
Fraction of window height to be used for terminating vertical bars on horizontal error bars (default 0.02).
DXSUB
Step size between ticks on the X-axis. If specified, it overrides any NXSUB (see below) value provided. It may be adjusted, however, if XMIN and XMAX are determined internally. It is ignored for logarithmic axes.
DYSUB
Step size between ticks on the Y-axis. If specified, it overrides any NYSUB (see below) value provided. It may be adjusted, however, if YMIN and YMAX are determined internally. It is ignored for logarithmic axes.
FILLIN(K)
Polygon fill indices for histogram bars in curve K. The default fill index for curve K is 6*(K-1), a cross-hatched diagonal pattern. Fill index 0 implies no filling. Values in the range 1-84 produce successively denser patterns, and values larger than 84 encode user-defined patterns. See manual page polyfill(1L).
HISTGM(K)
.TRUE. - Plot histogram of curve K. Histogram creation is done separately from interpolation so that both may be superimposed if desired. If this option is selected for curve K, then one should ordinarily set LSTYLE(K) = 0 to suppress connecting of the data points.

.FALSE. - No histogram of curve K (default). An ordinary line graph will be generated.
HMASK(K)
.TRUE. - Mask histogram bars in curve K against all succeeding plotted bars.

.FALSE. - No histogram bar masking (default). Bars may overlap one another.
HSCALE
Normally, the plot is made inside a frame 6.5 inches high and 9.0 inches wide centered inside an outer 8.5 x 11.0 inch frame, with numbering and labelling in the 1 inch margin. These values may be slightly different when the standard paper size is not ANSI A format. Sometimes, the numbers occupy too much space, and shrinking the inner frame is desirable. HSCALE may be provided as a number in the range 0.0-1.0 to scale the frame horizontally. (See also VSCALE below). A square inner frame may be obtained by setting HSCALE = 6.5/9.0 = 0.722222.
IDFONT
Hershey font identifier. Of the 144 font varieties available with the Hershey fonts, the following are available in this routine by a value for IDFONT in the range 1-5: 1 - UCKR1/UCKG1/UCII1/UCSS1 (Cartographic Roman/Greek, Indexical Italic, Simplex Script) 2 - UCSR1/UCSG1/UCII1/UCSS1 (Simplex Roman/Greek, Indexical Italic, Simplex Script) 3 - UCCR1/UCCG1/UCCI1/UCCS1 (Complex Roman/Greek, Complex Italic, Complex Script) (Default) 4 - UCTR1/UCCG1/UCCI1/UCCS1 (Triplex Roman, Complex Greek, Complex Italic, Complex Script) 5 - UCDR1/UCCG1/UCCI1/UCCS1 (Duplex Roman, Complex Greek, Complex Italic, Complex Script) The font selector characters are:

@ -- Roman (default)

# -- Greek

! -- Italic

& -- Script A doubled selector character will be treated as a single appearance of that character rather than as a font selector character. For example, the string Wolf (!Canis Lupus@)!! would result in "Wolf ()!" in Roman letters, and "Canis Lupus" in italics. See the documentation for SYMTX and the Hershey fonts for details.

INTGRT(K)
.TRUE. - Plot integral of curve K. This is drawn with the same line type as the curve itself, but no data point symbols are marked.

.FALSE. - No integration (default).
KX
Number of sets of X values. If not supplied, KX will be set to the index of the last curve for which a value has been set in X(1,KX). If entries beyond the KX-th position are found in XSHIFT(*) or XFACT(*), and KX is being determined automatically, then the KX-th set of X values will be automatically copied into succeeding sets and KX incremented accordingly. For example, one may wish to plot several sets histogram bars scaled or shifted about a common set of X values; by not specifying KX, only one set of X values need be provided.
KY
Number of sets of Y values. If not supplied, KY will be set to the index of the last curve for which a value has been set in Y(1,KY). If KX .NE. KY, the last set of X or Y values will be assumed to apply to the remaining ones. Thus, if there are 3 sets of Y values, each having the same X values, set KY=3 and KX=1, so that the X values need not be input three times. If entries beyond the KY-th position are found in YSHIFT(*) or YFACT(*), and KY is being determined automatically, then the KY-th set of Y values will be automatically copied into succeeding sets and KY incremented accordingly.
LISTXY
.TRUE. - Print the input X and Y values (default).

.FALSE. - Suppress the printing of the input X and Y values.
LOGX
.TRUE. - Logarithmic X-axis. When LOGX is found to be .TRUE., the corresponding X data values are replaced by their base-10 logarithms. The conversion is done only once, even if the RESET=.FALSE. option is used.

.FALSE. - Linear X-axis (default).
LOGY
.TRUE. - Logarithmic Y-axis. When LOGY is found to be .TRUE., the corresponding Y data values are replaced by their base-10 logarithms. The conversion is done only once, even if the RESET=.FALSE. option is used.

.FALSE. - Linear Y-axis (default).
LSTYLE(K)
The line style (1,2,...) to be used for curve K. See manual page linestyle(1L). The default is 1, which produces a solid line. Other values (2,3,...) give a variety of dashed lines. If LSTYLE(K) <= 0, then the data points for curve K are not connected by line segments. In such a case, one should normally set NU(K) = 1, so that a mark is placed at each point.
LWIDTH(K)
The line width (0.0-1.0) to be used for curve K. The default is 0.0, giving a line of minimal width. The width doubles for each increment of 0.05.
MARK(K)
The plot symbol used for marking points on curve K (1-20). See manual page markstyle(1L). The default is K. Markers are not drawn on curve K unless the marking frequency, NU(K) (see below), is greater than 0. A 0 entry in MARK(*) suppresses the marker; it may be used in conjunction with the error bar parameters.
MODEX
Labelling and numbering mode for X-axis. This is set by adding one or more of the following option values, and then setting the sign of the resulting sum to select numbering and titling above (+) or below (-) the axis.

1 - Number the axis. Even values of MODEX suppress numbering, but still affect the choice of tick mark spacing.

2 - Number perpendicularly (rotated -90 degrees) to the axis; otherwise it is parallel to the axis.

4 - Omit the first number along the axis. This can be useful to prevent text overlap when more than one axis is drawn from a point.

8 - Omit the last number along the axis.

16 - Omit any zero number along the axis. This can be useful for drawing axes intersecting at the origin (not applicable if logarithmic axes have been requested).

Any value outside the legal range of -31 to 31 (or -15 to 15 if logarithmic axes have been requested) will raise an error condition. The usual choice for a numbered lower horizontal (X) axis will be MODEX=-1, and for an unnumbered upper horizontal axis will be MODEX=0.

The sizes and positions of number labels, even if they are not drawn, affect the choice of where longer tick marks are drawn. In the common case where the four sides of a graph have axes, but two are unnumbered, for the unnumbered axes, simply subtract 1 from the unsigned MODEX value used for the opposite numbered axis.

MODEY
Labelling and numbering mode for Y-axis. See remarks for MODEX. The usual choice for a numbered left vertical (Y) axis will be MODEY=+3, and for an unnumbered right vertical axis will be MODEY=+2 or -2.
N(K)
The number of points in curve K. Normally, the number N(K) will be determined automatically by finding the last user-provided entry in X(*,K) or Y(*,K). If it is desired to plot fewer points than there are data values, then N(K) should be explicitly specified. A value of 0 will suppress plotting of the corresponding curve.
NU(K)
The symbol-plotting frequency for curve K. Every NU(K)-th point will be marked with symbol MARK(K). The default is 0, for which marking is suppressed.
NUMINT(K)
The total number of points to interpolate on curve K for plotting. If zero, no spline interpolation will be done for that curve (default).
NXSUB
Number of X-axis subdivisions if scale linear. If negative, the number of subdivisions will be adjusted to approximately -NXSUB to obtain "nice" values (default).
NYSUB
Number of Y-axis subdivisions if scale linear. If negative, the number of subdivisions will be adjusted to approximately -NYSUB to obtain "nice" values (default).
PEN(K)
Pen numbers for curve K. The meaning of these numbers (1,2,...) must generally be agreed upon in advance with the plotter operator. The default is 1. On a pen plotter, this is usually a black pen.
PENDIA
Pen diameter scale factor (default 0.0). This option allows one to simulate a thick pen when text is drawn. Each character is drawn repeatedly, stepping its origin around a small circle representing the pen diameter. For convenience, the diameter value is given as a fraction of the character height, rather than as an absolute number. A value of about 0.01 to 0.03 often gives reasonable results. A value of 0.0 will revert to normal text plotting.
RESET
.TRUE. - Reset defaults for next set of input data (default).

.FALSE. - Use current parameter values as defaults for next set of input data. This is useful for producing several plots with perhaps different scales and axis types from the same set of data points.
SIGMA(K)
The tensioned spline parameter for curve K. See manual page splinepar(1L). Default 1.0.
SIZECM
Size in centimeters of the plot unit square on the selected plot device. Default is 27.94 (11 inches), or whatever is the longest dimension of the local standard paper size. If both SIZECM and SIZEIN are specified, SIZEIN is used.
SIZEIN
Size in inches of the plot unit square on the selected plot device. Default is 11.0, or whatever is the longest dimension of the local standard paper size.
SIZEMK
Marker height scale factor (default 1.0). Marker heights can be uniformly scaled up or down by changing this value.
TICKX
Length (inches) of tick marks on X-axis. If ABS(TICKX) > 6.5, vertical grid lines will be drawn.
TICKY
Length (inches) of tick marks on Y-axis. If ABS(TICKY) > 9.0, horizontal grid lines will be drawn.
VSCALE
Vertical scale factor (0.0-1.0: values outside this range will be reset to 1.0). See the remarks on HSCALE above.
XAXIS
.TRUE. - draw X axis (default).

.FALSE. - suppress X axis.
XFACT(K)
Input X-data scale factors for curve K. The input values X(*,K) will be multiplied by XFACT(K). This is frequently convenient to avoid having to type decimal points in the X-values. After use, XFACT(K) is reset to 1.0 to avoid rescaling the data if it is reused on a subsequent pass with RESET=.FALSE.
XFALLS
.TRUE. - Descending X scale.

.FALSE. - Ascending X scale (default).
XMAX
Maximum X value to plot. It is perfectly permissible for data points to lie outside the range (XMIN,XMAX) and (YMIN,YMAX). If XMIN and XMAX are not supplied, "nice" values will be determined automatically. For a logarithmic axis (LOGX = .TRUE.), XMIN and XMAX represent the extremes before conversion to logarithms, and should normally be chosen to be powers of ten.
XMIN
Minimum X value to plot.
XMINUS(K)
Minus error bar values for X data of curve K. See XPLUS(*) below.
XPLUS(K)
Plus error bar values for X data of curve K. Error bars are placed every NU(K) points on curve K, just like markers. Positive entries in XPLUS(*) represent absolute errors, and negative entries relative errors. They are applied after any scaling and translation are done on the input points. On curve K, a horizontal error bar will be drawn between X(I,K) - ABS(XMINUS(K)) and X(I,K) + ABS(XPLUS(K)) for absolute errors, or between X(I,K)*(1.0 - ABS(XMINUS(K))) and X(I,K)*(1.0 + ABS(XPLUS(K))) for relative errors. This does not offer the luxury of individual error bars for each point, but requires only 4 extra numbers for each curve, if both X and Y error bars are desired.
XSHIFT(K)
Shift constants for X data of curve K. XSHIFT(K) will be added to X(*,K) after multiplying the input X(*,K) values by XFACT(*). After use, XSHIFT(K) is reset to 0.0 to avoid shifting the data again if it is reused on a subsequent pass with RESET=.FALSE.
YBASE(K)
The base point of the bars for histogram K. Points Y(I,K) which exceed YBASE(K) will have bars going upward, while points Y(I,K) below YBASE(K) will have bars going downward (default YMIN).
YAXIS
.TRUE. - draw Y axis (default).

.FALSE. - suppress Y axis.
YFACT(K)
Y-data scale factors for curve K. The input values Y(*,K) will be multiplied by YFACT(K). After use, YFACT(K) is reset to 1.0 to avoid rescaling the data if it is reused on a subsequent pass with RESET=.FALSE.
YFALLS
.TRUE. - Descending Y scale.

.FALSE. - Ascending Y scale (default).
YMAX
Maximum Y value to plot. See remarks about XMAX and XMIN above.
YMIN
Minimum Y value to plot.
YMINUS(K)
Minus error bar values for Y data of curve K. See YPLUS(*) below.
YPLUS(K)
Plus error bar values for Y data of curve K. Error bars are placed every NU(K) points on curve K, just like markers. They are applied after any scaling and translation are done on the input points. Positive entries in YPLUS(*) represent absolute errors, and negative entries relative errors. On curve K, a vertical error bar will be drawn between Y(I,K) - ABS(YMINUS(K)) and Y(I,K) + ABS(YPLUS(K)) for absolute errors, or between Y(I,K)*(1.0 - ABS(YMINUS(K))) and Y(I,K)*(1.0 + ABS(YPLUS(K))) for relative errors. This does not offer the luxury of individual error bars for each point, but requires only 4 extra numbers for each curve if both X and Y are desired.
YSHIFT(K)
Shift constants for Y data of curve K. YSHIFT(K) will be added to Y(*,K) after multiplying the input Y(*,K) values by YFACT(*). After use, YSHIFT(K) is reset to 0.0 to avoid shifting the data again if it is reused on a subsequent pass with RESET=.FALSE.
YSTACK(K)
LOGICAL bar stacking flags. If .TRUE., the histogram bar heights for curves L = 1..K-1 for which: 1) HISTGM(L) = .TRUE., 2) YSTACK(L) = .TRUE., and 3) X values match, will be summed to determine an additional increment to the baseline of bar K, thereby stacking the bar on top of previous ones (default .FALSE.).

A NOTE ABOUT DATA STORAGE

The points in a given curve are in consecutive storage locations (i.e. in the columns of X(*,*) and Y(*,*)). Because few FORTRAN implementations provide bounds checking, it is possible for the user to specify more than MAXVAL points in a single curve. For example, if two curves each containing between 2*MAXVAL and 3*MAXVAL points were to be plotted, one could enter them as curves 1 and 4, explicitly setting N(*) = n1, 0, 0, n2. A single curve of as many as MAXVAL*MAXCRV points could be plotted using this trick.