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