GRAP(1)

NAME
grap - pic preprocessor for drawing graphs

SYNOPSIS
grap [-SU] [file]

DESCRIPTION
Grap is a pic(1) preprocessor for drawing graphs on a typesetter. Graphs are surrounded by the troff `commands' .G1 and .G2. Data are scaled and plotted, with tick marks supplied automatically. Commands exist to modify the frame, add labels, override the default ticks, change the plotting style, define coordinate ranges and transformations, and include data from files. In addition, grap provides the same loops, conditionals, and macro processing that pic does.

frame ht e wid e top dotted ...: Set the frame around the graph to specified ht and wid; default is 2 by 3 (inches). The line styles (dotted, dashed, invis, solid (default)) of the sides (top, bot, left, right) of the frame can be set independently.

label side "a label" "as a set of strings" adjust: Place label on specified side; default side is bottom. adjust is up (or down left right) expr to shift default position; width expr sets the width explicitly.

ticks side in at optname expr, expr, ...: Put ticks on side at expr, ..., and label with "expr". If any expr is followed by "...", label tick with "...", and turn off all automatic labels. If "..." contains %f's, they will be interpreted as printf formatting instructions for the tick value. Ticks point in or out (default out). Tick iterator: instead of at ..., use from expr to expr by op expr where op is optionally +-*/ for additive or multiplicative steps. by can be omitted, to give steps of size 1. If no ticks are requested, they are supplied automatically; suppress this with ticks off. Automatic ticks normally leave a margin of 7% on each side; set this to anything by margin = expr.

grid side linedesc at optname expr, expr, ...: Draw grids perpendicular to side in style linedesc at expr, .... Iterators and labels work as with ticks.

coord optname x min, max y min, max log x log y: Set range of coords and optional log scaling on either or both. This overrides computation of data range. Default value of optname is current coordinate system (each coord defines a new coordinate system).

plot "str" at point; "str" at point: Put str at point. Text position can be qualified with rjust, ljust, above, below after "...".

line from point to point linedesc: Draw line from here to there. arrow works in place of line.

next optname at point linedesc: Continue plot of data in optname to point; default is current.

draw optname linedesc ...: Set mode for next: use this style from now on, and plot "..." at each point (if given).

new optname linedesc ...: Set mode for next, but disconnect from previous.

A list of numbers x y1 y2 y3 ... is treated as plot bullet at x,y1; plot bullet at x,y2; etc., or as next at x,y1 etc., if draw is specified. Abscissae of 1,2,3,... are provided if there is only one input number per line.

A point optname expr, expr maps the point to the named coordinate system. A linedesc is one of dot dash invis solid optionally followed by an expression.

define name {whatever}: Define a macro. There are macros already defined for standard plotting symbols like bullet, circle, star, plus, etc., in /sys/lib/grap.defines, which is included if it exists.

var = expr: Evaluate an expression. Operators are + - * and /. Functions are log and exp (both base 10), sin, cos, sqrt; rand returns random number on [0,1); max(e,e), min(e,e), int(e).

print expr; print "...": As a debugging aid, print expr or string on the standard error.

copy "file name": Include this file right here.

copy thru macro: Pass rest of input (until .G2) through macro, treating each field (non-blank, or "...") as an argument. macro can be the name of a macro previously defined, or the body of one in place, like /plot $1 at $2,$3/.

copy thru macro until "string": Stop copy when input is string (left-justified).

pic remainder of line: Copy to output with leading blanks removed.

graph Name pic-position: Start a new frame, place it at specified position, e.g., graph Thing2 with .sw at Thing1.se + (0.1,0). Name must be capitalized to keep pic happy.

.anything at beginning of line: Copied verbatim.

sh %anything %: Pass everything between the %'s to the shell; as with macros, % may be any character and anything may include newlines. The -S option disables execution of the shell command; the -U option reverts the effect of a previous -S.

# anything: A comment, which is discarded.

Order is mostly irrelevant; no category is mandatory. Any arguments on the .G1 line are placed on the generated .PS line for pic.

FILES

/usr/local/libexec/heirloom-doctools/grap.defines
    definitions of standard plotting characters, e.g., bullet

SEE ALSO
pic(1), troff(1)
J. L. Bentley and B. W. Kernighan, ``GRAP—A Language for Typesetting Graphs'', Unix Research System Programmer's Manual, Tenth Edition, Volume 2.