Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ grap(1M) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

pic(1M)

grap(1M)                                                           grap(1M)

NAME
     grap - pic preprocessor for drawing graphs

SYNOPSIS
     grap file ...

DESCRIPTION
     grap is a pic(1M) preprocessor for drawing graphs on a typesetter.
     Graphs are surrounded by the troff commands .G1 and .G2. Data that is
     enclosed is scaled and plotted, with tick marks supplied automati-
     cally. 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 pro-
     vides 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 default mode applies to all four sides;
          top, bot, left, or right can be set to dotted, dashed, invis, or
          solid 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 inter-
          preted 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 o expr where o 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 nor-
          mally 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).







Page 1                       Reliant UNIX 5.44                Printed 11/98

grap(1M)                                                           grap(1M)

     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 speci-
     fied. 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 sys-
     tem. 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
          /usr/lib/dwb/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 "filename":
          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).




Page 2                       Reliant UNIX 5.44                Printed 11/98

grap(1M)                                                           grap(1M)

     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.

     # 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.


































Page 3                       Reliant UNIX 5.44                Printed 11/98

grap(1M)                                                           grap(1M)

EXAMPLES
     .G1
     frame ht 2 wid 2
     coord x 0,100 y 0,100
     grid dotted bot from 20 to 80 by 20
     grid dotted left from 20 to 80 by 20

     "Text above"   above at 50,50
     "Text rjust "  rjust at 50,50
     bullet at 80,90
     vtick  at 80,80
     box    at (80,70)
     times  at 80,60

     circle at 50,50
     circle at 50,80 radius .25
     line dashed from 10,90 to 30,90
     arrow from 10,70 to 30,90

     draw A solid
     draw B dashed delta
     next A at 10,10
     next B at 10,20
     next A at 50,20
     next A at 90,10
     next B at 50,30
     next B at 90,30
     .G2

     Result: See System Administrator's Reference Manual!

     .G1
     frame invis ht 2 wid 3 left solid bot solid
     label left "Time" "(in seconds)" left .2
     label bot "Olympic 400 Meter Run: Winning Times"
     coord x 1894,1982 y 42,56
     ticks left out at 44 "44", 46, 48 "48", 50, 52 "52", 54
     ticks bot in from 1900 to 1980 by 20
     draw solid
     1896 54.2
     1900 49.4
     1904 49.2
     1908 50.0
     1912 48.2
     1920 49.6
     1924 47.6
     1928 47.8
     1932 46.2
     1936 46.5
     1948 46.2
     1952 45.9
     1956 46.7


Page 4                       Reliant UNIX 5.44                Printed 11/98

grap(1M)                                                           grap(1M)

     1960 44.9
     1964 45.1
     1968 43.8
     1972 44.6
     1976 44.2
     1980 44.6
     .G2

     Result: See System Administrator's Reference Manual!

     If you place the list of dates and winning times in a separate file
     called 400mpairs.d, and then include this file with copy, the specifi-
     cation is reduced to the following lines:

     .G1
     frame invis ht 2 wid 3 left solid bot solid
     label left "Time" "(in seconds)" left .2
     label bot "Olympic 400 Meter Run: Winning Times"
     coord x 1894,1982 y 42,56
     ticks left out at 44 "44", 46, 48 "48", 50, 52 "52", 54
     ticks bot in from 1900 to 1980 by 20
     draw solid
     copy "400mpairs.d"
     .G2

FILES
     /usr/lib/dwb/grap.defines

SEE ALSO
     pic(1M).

     J. L. Bentley and B. W. Kernighan, GRAP - A Language for Typesetting
     Graphs, CSTR 114, 1984





















Page 5                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026