Troff "grap" question
Mark Brader
msb at sq.uucp
Mon Dec 5 12:05:56 AEST 1988
> How can i tell "grap" that there is a gap in the x-axis; that week 8901 is the
> successor of week 8852 and NOT 8900 !
Probably the easiest way is to turn that number into something that'll
increase linearly, by arithmetic operations. You turn 8852 into 88+51/52
and 8901 into 89. If the year and week number, in combined form as in 8852,
is w, then the value you want to use is: (w%100-1)/52 + int(w/100)
One way to achieve this transformation is to precede the list of data points
with the following grap command:
copy thru @ next at (($1%100-1)/52 + int($1/100), $2) @
(The @ characters are delimiters for the body of "copy thru".)
Then each data line, say
8842 166.9
will cause a point to be plotted at
((88%100-1)/52 + int(88/100), 166.9)
which is (88+41/52, 166.9) which is what you want.
You do still have to declare your own ticks for the x-axis if you want
meaningful labels on them, though. You might say:
ticks bot at 87 "Jan 1987", \
87.5 "Jul 1987", \
88 "Jan 1988", \
88.5 "Jul 1988", \
89 "Jan 1989", \
89.5 "Jul 1989", \
90 "Jan 1990"
Or you might have a tick for every week and not label them.
ticks bot from 87 to 90 by 1/52 ""
Or you might do both. You can plot multiple sets of ticks on the same axis;
they just overprint on top of each other.
An alternative general approach is to define a new set of coordinates
(using the "coord" keyword) for each year; this involves more nuisance,
but does enable you to get numerical week labels for each year if you want.
The following will again plot from the beginning of 1987 to the beginning
of 1990, but you get ticks at 8701, 8710, 8720, 8730, 8740, 8801, etc.
coord yr87 x 8701 ,8701+3*52 y 0,200
coord yr88 x 8801- 52,8801+2*52 y 0,200
coord yr89 x 8901-2*52,8901+ 52 y 0,200
coord yr90 x 9001-3*52,9001 y 0,200
ticks bot at yr87 8701
ticks bot from yr87 8710 to 8740 by 10
ticks bot at yr88 8801
ticks bot from yr88 8810 to 8840 by 10
ticks bot at yr89 8901
ticks bot from yr89 8910 to 8940 by 10
ticks bot at yr90 9001
Then you'd have to plot each point in the appropriate coordinate system.
Put the following just above the list of data points:
copy thru !
year = int($1/100)
if (year <= 87) then @ next at yr87 ($1, $2) @
if (year == 88) then @ next at yr88 ($1, $2) @
if (year == 89) then @ next at yr89 ($1, $2) @
if (year >= 90) then @ next at yr90 ($1, $2) @
!
You could also make it more robust by checking whether "year" was in range.
Note: Both of the above methods have been tested with our version of grap,
which is called sqgrap and is included with SoftQuad Publishing Software.
I have not tried them with any earlier versions of grap.
Mark Brader "... there is no such word as 'impossible' in
SoftQuad Inc., Toronto my dictionary. In fact, everything between
utzoo!sq!msb 'herring' and 'marmalade' appears to be missing."
msb at sq.com -- Douglas Adams: Dirk Gently's Holistic Detective Agency
More information about the Comp.unix.questions
mailing list