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