GRAP(1)

๐ŸŒธ NAME ๐ŸŒธ

grap โ€” pic preprocessor for drawing graphs. Hi bestie, this is the GRAP(1) page from the General Commands Manual, and yes, we're about to make graphs slay. ๐Ÿ’…


๐Ÿ“œ SYNOPSIS ๐Ÿ“œ

grap [ 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. Highkey, independent side styling is iconic. โœจ
  • label side "a label" "as a set of strings" adjust โ€” place a label on the specified side; default side is bottom. adjust is up (or down left right) expr to shift the 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. fr fr, tick math is giving main character energy. ๐Ÿ“
  • 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). Obsessed with a fresh coordinate system, honestly. ๐Ÿฆ‹
  • 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. Fresh start, no strings attached. ๐Ÿ’ซ
  • 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. ๐Ÿ“
  • 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. It's giving line-style menu, and I'm not mad at it. ๐Ÿ’…
  • define name {whatever} โ€” define a macro. There are macros already defined for standard plotting symbols like bullet, circle, star, plus, etc., in /lib/grap.defines, which is included if it exists. This macro moment ate. ๐Ÿ‘‘
  • 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. Not me using debug prints as a personality trait. ๐Ÿ™ˆ
  • 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/. iykyk. ๐Ÿงš
  • 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. Do not skip the capital, bestie โ€” that's a real vibe check. ๐Ÿšจ
  • .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. Bye, comment. ๐Ÿ’จ

Order is mostly irrelevant; no category is mandatory. Any arguments on the .G1 line are placed on the generated .PS line for pic. No cap. ๐ŸŒˆ


๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

Literally copy this lil graph era:

.G1
frame ht 1 top invis right invis
coord x 0, 10 y 1, 3 log y
ticks left in at 1 "bottommost tick", 2,3 "top tick"
ticks bot in from 0 to 10 by 2
label bot "silly graph"
label left "left side label" "here"
grid left dashed at 2.5
copy thru / circle at $1,$2 /
1 1
2 1.5
3 2
4 1.5
10 3
.G2
frame ht 1 top invis right invis
coord x 0, 10 y 1, 3 log y
ticks left in at 1 "bottommost tick", 2,3 "top tick"
ticks bot in from 0 to 10 by 2
label bot "silly graph"
label left "left side label" "here"
grid left dashed at 2.5
copy thru / circle at $1,$2 /
1 1
2 1.5
3 2
4 1.5
10 3

๐ŸŽ€ FILES ๐ŸŽ€

  • /lib/grap.defines โ€” definitions of standard plotting characters, e.g., bullet. ๐Ÿ–๏ธ

๐Ÿงš SOURCE ๐Ÿงš

  • /src/cmd/grap โ€” the source, bestie. ๐Ÿซถ

๐ŸŒŸ 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.

๐Ÿ’– That's the whole page, bestie. Source: /src/cmd/grap; footer/version tag: GRAP(1); date: not printed on this page. Periodt. ๐Ÿ’–