1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
|
.TH GRAP 1
.SH NAME
grap \- pic preprocessor for drawing graphs
.SH SYNOPSIS
.B grap
[
.I file ...
]
.SH DESCRIPTION
.I Grap
is a
.MR pic (1)
preprocessor for drawing graphs on a typesetter.
Graphs are surrounded by the
.I troff
`commands'
.B \&.G1
and
.BR \&.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,
.I grap
provides the same loops, conditionals, and macro processing that
.I pic
does.
.PP
.BI frame
.B ht
.I e
.B wid
.I e
.B top
.B dotted
.IR ... :
Set the frame around the graph to specified
.B ht
and
.BR wid ;
default is 2 by 3 (inches).
The line
.I styles
.RB ( dotted ,
.BR dashed ,
.BR invis ,
.BR solid
(default))
of the
.I sides
.RB ( top ,
.BR bot ,
.BR left ,
.BR right )
of the frame can be set
independently.
.PP
.B label
.I side
.B \&"a label"
.B \&"as a set of strings"
.IR adjust :
Place label on specified side; default side is bottom.
.I adjust
is
.B up
(or
.B down
.B left
.BR right )
.I expr
to shift default position;
.B width
.I expr
sets the width explicitly.
.PP
.BI ticks
.I side
.B in
.B at
.IR "optname expr, expr, ..." :
Put ticks on
.I side
at
.I "expr, ...,
and label with
.I \&"expr"\f1.
If any
.I expr
is followed by "...", label tick with "...",
and turn off all automatic labels.
If "..." contains
.BR %f 's,
they will be interpreted as
.B printf
formatting instructions for the tick value.
Ticks point
.B in
or
.B out
(default out).
Tick iterator: instead of
.B at
.IR \&... ,
use
.BI from
.I expr
.B to
.I expr
.B by
.I "op expr
where
.I op
is optionally
.B +-*/
for additive or multiplicative steps.
.B by
can be omitted, to give steps of size 1.
If no ticks are requested, they are supplied automatically;
suppress this with
.B ticks
.BR off .
Automatic ticks normally
leave a margin of 7% on each side; set this to anything by
.B margin
.B =
.IR expr .
.PP
.B grid
.I "side linedesc"
.B at
.IR "optname expr, expr, ..." :
Draw grids perpendicular to
.I side
in style
.I linedesc
at
.I "expr, ....\&
Iterators and labels work as with ticks.
.PP
.B coord
.I optname
.B x
.I "min, max"
.B y
.I "min, max"
.B "log x
.BR " log y" :
Set range of coords and optional log scaling on either or both.
This overrides computation of data range.
Default value of
.I optname
is current coordinate system
(each
.B coord
defines a new coordinate system).
.PP
.B plot
.I \&"str"
.B at
.IR point ;
.B
.I \&"str"
.B at
.IR point :
Put
.I str
at
.IR point .
Text position can be qualified with
.BR rjust ,
.BR ljust ,
.BR above ,
.BR below
after "...".
.PP
.B line
.B from
.I point
.B to
.IR "point linedesc" :
Draw line from here to there.
.B arrow
works in place of
.BR line .
.PP
.B next
.I optname
.B at
.IR "point linedesc" :
Continue plot of data in
.I optname to
.IR point ;
default is current.
.PP
.BI draw
.IR "optname linedesc ..." :
Set mode for
.BR next :
use this style from now on,
and plot "..." at each point (if given).
.PP
.BI new
.IR "optname linedesc ..." :
Set mode for
.BR next ,
but disconnect from previous.
.PP
A list of numbers
.I "x y1 y2 y3 ...
is treated as
.B plot
.B bullet
.B at
.IR x,y1 ;
.B plot
.B bullet
.B at
.IR x,y2 ;
etc., or as
.B next
.B at
.I x,y1
etc., if
.B draw
is specified.
Abscissae of 1,2,3,... are provided if there is only one input number per line.
.PP
A
point
.I "optname expr, expr
maps the point to the named coordinate system.
A
.I linedesc
is one of
.B dot
.B dash
.B invis
.B solid
optionally followed by an expression.
.PP
.BI define
.I name
.BI { whatever } \f1:
Define a macro.
There are macros already defined for standard plotting
symbols like
.BR bullet ,
.BR circle ,
.BR star ,
.BR plus ,
etc., in
.BR \*9/lib/grap.defines ,
which is included if it exists.
.PP
.I var
.B =
.IR expr :
Evaluate an expression.
Operators are
.B=
.B +
.B -
.B *
and
.BR / .
Functions are
.B log
and
.B exp
(both base 10),
.BR sin ,
.BR cos ,
.BR sqrt ;
.B rand
returns random number on [0,1);
.BI max( e , e )\f1,
.BI min( e , e )\f1,
.BI int( e )\f1.
.PP
.B print
.IR expr ;
.B print
\fL"\f2...\fL"\f1:
As a debugging aid, print
.I expr
or
.I string
on the standard error.
.PP
.B copy
\fL"\fIfile name\fL"\fR:
Include this file right here.
.PP
.B copy
.B thru
.IR macro :
Pass rest of input (until
.BR \&.G2 )
through
.IR macro ,
treating each field (non-blank, or "...") as an argument.
.I macro
can be the name of a macro previously defined,
or the body of one in place, like
.BR "/plot $1 at $2,$3/" .
.PP
.B copy
.B thru
.I macro
.B until
\fL"\fIstring\fL"\fR:
Stop copy when input is
.I string
(left-justified).
.PP
.BI pic
.IR "remainder of line" :
Copy to output with leading blanks removed.
.PP
.BI graph
.IR "Name pic-position" :
Start a new frame, place it at specified position,
e.g.,
.B graph
.B Thing2
.BR "with .sw at Thing1.se + (0.1,0)" .
.I Name
must be capitalized to keep
.I pic
happy.
.PP
.BI \&. "anything at beginning of
.IR line :
Copied verbatim.
.PP
.B sh
.BI % anything
.BR % :
Pass everything between the
.BR % 's
to the shell;
as with macros,
.B %
may be any character and
.I anything
may include newlines.
.PP
.B #
.IR anything :
A comment, which is discarded.
.PP
Order is mostly irrelevant; no category is mandatory.
Any arguments on the
.B \&.G1
line are placed on the generated
.B \&.PS
line for
.IR pic .
.SH EXAMPLES
.EX
.ps -1
.vs -1
\&.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
.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
.ps
.vs
.EE
.SH FILES
.TF \*9/lib/grap.defines
.TP
.B \*9/lib/grap.defines
definitions of standard plotting characters, e.g., bullet
.SH SOURCE
.B \*9/src/cmd/grap
.SH "SEE ALSO"
.IR pic (1),
.MR troff (1)
.br
J. L. Bentley and B. W. Kernighan,
``GRAP\(emA Language for Typesetting Graphs'',
.I
Unix Research System Programmer's Manual,
Tenth Edition, Volume 2.
|