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 specifiedhtandwid; default is2by3(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 specifiedside; default side isbottom.adjustisup(ordown left right)exprto shift the default position;width exprsets the width explicitly. ๐ticks side in at optname expr, expr, ...โ put ticks onsideatexpr, ..., and label with"expr". If anyexpris followed by"...", label tick with"...", and turn off all automatic labels. If"..."contains%f's, they will be interpreted asprintfformatting instructions for the tick value. Ticks pointinorout(defaultout). Tick iterator: instead ofat ..., usefrom expr to expr by op exprwhereopis optionally+-*/for additive or multiplicative steps.bycan be omitted, to give steps of size1. If no ticks are requested, they are supplied automatically; suppress this withticks off. Automatic ticks normally leave a margin of7%on each side; set this to anything bymargin = expr. fr fr, tick math is giving main character energy. ๐grid side linedesc at optname expr, expr, ...โ draw grids perpendicular tosidein stylelinedescatexpr, .... Iterators and labels work as withticks. ๐ธ๏ธcoord optname x min, max y min, max log x log yโ set range of coords and optionallogscaling on either or both. This overrides computation of data range. Default value ofoptnameis current coordinate system (eachcoorddefines a new coordinate system). Obsessed with a fresh coordinate system, honestly. ๐ฆplot "str" at point; "str" at pointโ putstratpoint. Text position can be qualified withrjust,ljust,above,belowafter"...". โจline from point to point linedescโ draw line from here to there.arrowworks in place ofline. โก๏ธnext optname at point linedescโ continue plot of data inoptnametopoint; default is current. ๐draw optname linedesc ...โ set mode fornext: use this style from now on, and plot"..."at each point (if given). ๐จnew optname linedesc ...โ set mode fornext, but disconnect from previous. Fresh start, no strings attached. ๐ซ- A list of numbers
x y1 y2 y3 ...is treated asplot bullet at x,y1; plot bullet at x,y2;etc., or asnext at x,y1etc., ifdrawis specified. Abscissae of1,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
linedescis one ofdotdashinvissolidoptionally 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 likebullet,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 arelogandexp(both base 10),sin,cos,sqrt;randreturns random number on[0,1);max(e,e),min(e,e),int(e). ๐งฎprint expr; print "..."โ as a debugging aid, printexpror 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) throughmacro, treating each field (non-blank, or"...") as an argument.macrocan 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 isstring(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).Namemust be capitalized to keeppichappy. 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 andanythingmay 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. ๐
๐ฆ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 ยท LPL-1.02
- arch rolling: plan9port 20261021-2 ยท custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms