aboutsummaryrefslogtreecommitdiffstats
path: root/doc/user/gra_data
blob: 323f155ecc77d2678d1ffe8d97c74a35b60e79b1 (plain) (blame)
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
@Section
   @Title { Changing the appearance of the data }
   @Tag { data }
@Begin
@PP
The @Code "@Data" symbol has options for controlling the
data. @Index @Code "@Data"
appearance of its data.  We have already seen the
@Code "points" option, which controls what is printed at each data
point:
points.graphs @Index { @Code "points" option in graphs }
@CD @Tab
   vmargin { 0.5vx }
   @Fmta { @Col @Code A ! @Col B ! @Col ! @Col @Code C ! @Col D }
{
@Rowa
    A { cross }
    B { @GraphCross }
    C { plus }
    D { @GraphPlus }
@Rowa
    A { square }
    B { @GraphSquare }
    C { filledsquare }
    D { @GraphFilledSquare }
@Rowa
    A { diamond }
    B { @GraphDiamond }
    C { filleddiamond }
    D { @GraphFilledDiamond }
@Rowa
    A { circle }
    B { @GraphCircle }
    C { filledcircle }
    D { @GraphFilledCircle }
@Rowa
    A { triangle }
    B { @GraphTriangle }
    C { filledtriangle }
    D { @GraphFilledTriangle }
}
If the @Code "points" option is omitted or empty, nothing is printed.  The
symbols are centred over the data point.  There is a @Code "symbolsize"
option which controls the size (radius) of all these symbols:
symbolsize. @Index { @Code "symbolsize" option in graphs }
@ID @OneRow @Code {
"@Data"
"    symbolsize { 0.15 ft }"
}
shows the default, 0.15 times the current font size.  More
precisely, the default value is taken from an option
to the @Code "@Graph" symbol, also called {@Code "symbolsize"}.  By
setting that option you can therefore set the symbol size of all data
points in the graph at once; its default value is {@Code "0.15 ft"}.
@PP
The @Code "@Data" symbol also has a @Code "pairs" option which
pairs. @Index { @Code "pairs" option in graphs }
determines how each pair of points is connected.  The choices are
@Code none (not connected, the default), @Code solid (a solid line),
@Code dashed (a dashed line), or @Code dotted (a dotted line).  For
example,
@ID @OneRow @Code {
"@Graph"
"    abovecaption { Estimated population of Boston, New York, and Philadelphia }"
"{"
"    @Data  points { plus }  pairs { solid }"
"    { 1720 12000  1730 13000  1740 15601  1760 15631  1770 15877 }"
""
"    @Data  points { plus }  pairs { dashed }"
"    { 1720 7000  1730 8622  1740 10451  1750 14255  1760 18000  1770 22667 }"
""
"    @Data  points { plus }  pairs { dotted }"
"    { 1720 10000  1730 11500  1740 12654  1750 18202  1760 23750  1770 34583 }"
"}"
}
produces
@CD @Graph
    abovecaption { Estimated population of Boston, New York, and Philadelphia
}
{
    @Data  points { plus }  pairs { solid }
    { 1720 12000  1730 13000  1740 15601  1760 15631  1770 15877 }

    @Data  points { plus }  pairs { dashed }
    { 1720 7000  1730 8622  1740 10451  1750 14255  1760 18000  1770 22667 }

    @Data  points { plus }  pairs { dotted }
    { 1720 10000  1730 11500  1740 12654  1750 18202  1760 23750  1770 34583 }

}
(R. C. Simmons, @I { The American Colonies }, W. W. Norton, New York,
1981.)  We will see in Section {@NumberOf key} how to add an explanatory key to
this graph.  If the points have symbols, these connecting lines will stop 1.5
symbolsizes away from the data points, so as not to overstrike them.  If
the points have no symbols and @Code "pairs" is {@Code "dashed"}, the
first and last dash in each segment will have half the length of the
others.
@PP
A @Code "dashlength" option controls the length of dashes and also the
separation between dots, and a @Code "linewidth" option controls the
width (thickness) of the lines and dots:
@ID @OneRow @Code {
"@Data"
"    dashlength { 0.2 ft }"
"    linewidth { 0.5 pt }"
"{"
"    ..."
"}"
}
This shows the default values, {@Code "0.2 ft"} for @Code "dashlength"
and {@Code "0.5 pt"} (half a point) for {@Code "linewidth"}.  Actually
the default value for @Code "linewidth" is whatever happens to be
already in use, but Lout sets line widths to half a point initially.
This option also controls the separation between bars in histograms.
@PP
The @Code "pairs" option is also used for producing histograms, like
histograms. @Index { histograms }
this:
@ID @OneRow @Code {
"@Graph"
"    hidecaptions { yes }"
"    abovecaption { Computer Science 3 Results (1993) }"
"    leftcaption { Number of"
"students }"
"    belowcaption { Final mark (%) }"
"    yextra { 0 cm }"
"    ymax { 80 }"
"{"
"    @Data pairs { yhisto }"
"    { 0 1 10 3 20 2 30 4 40 15 50 60 60 58 70 28 80 15 90 7 100 0 }"
"}"
}
which has result
@CD @Graph
    hidecaptions { yes }
    abovecaption { Computer Science 3 Results (1993) }
    leftcaption { Number of
students }
    belowcaption { Final mark (%) }
    yextra { 0 cm }
    ymax { 80 }
{
    @Data
        pairs { yhisto }
    { 0 1 10 3 20 2 30 4 40 15 50 60 60 58 70 28 80 15 90 7 100 0 }
}
Note carefully that one y histogram rectangle occupies the space from
one x value to the next, with height equal to the y value lying between
these two x values.  This means that the very last y value has no effect
on the result (however, there must be a last y value anyway).
@PP
There is an alternative to @Code "yhisto" called {@Code "surfaceyhisto"}:
@CD @Graph
    hidecaptions { yes }
    abovecaption { Computer Science 3 Results (1993) }
    leftcaption { Number of
students }
    belowcaption { Final mark (%) }
    yextra { 0 cm }
    ymax { 80 }
{
    @Data
        pairs { surfaceyhisto }
    { 0 1 10 3 20 2 30 4 40 15 50 60 60 58 70 28 80 15 90 7 100 0 }
}
As you can see, @Code "surfaceyhisto" draws just the surface of the
histogram, not the descending lines.
@PP
There are @Code "xhisto" and @Code "surfacexhisto" values of
@Code "pairs" which produce a histogram whose bars are parallel to
the x axis.  There are also {@Code "filledyhisto" } and
{@Code "filledxhisto" } values which produce filled rectangles rather
than outlined ones:
@ID @OneRow @Code {
"@Graph"
"    abovecaption { Fertility rates in some developing countries }"
"    xextra { 0 cm }"
"    yextra { 0 cm }"
"    xmax { 8 }"
"    yticks {"
"        1.5 (Turkey) 2.5 (Thailand)"
"        3.5 (Indonesia) 4.5 (Costa Rica)"
"        5.5 (Colombia) 6.5 (Cameroon)"
"        7.5 (Botswana) 8.5 (Bangladesh)"
"    }"
"    yticklength { 0 cm }"
"{"
"    @Data"
"        pairs { filledxhisto }"
"    { 0 1 3.2 2 2.2 3 3.0 4 3.5 5 2.8 6 5.9 7 4.8 8 5.3 9 }"
"}"
}
produces
@CD @Graph
    abovecaption { Fertility rates in some developing countries
    }
    xextra { 0 cm }
    yextra { 0 cm }
    xmax { 8 }
    yticks { 1.5 (Turkey) 2.5 (Thailand) 3.5 (Indonesia) 4.5 (Costa Rica)
             5.5 (Colombia) 6.5 (Cameroon) 7.5 (Botswana) 8.5 (Bangladesh) }
    yticklength { 0 cm }
{
    @Data
        pairs { filledxhisto }
    { 0 1 3.2 2 2.2 3 3.0 4 3.5 5 2.8 6 5.9 7 4.8 8 5.3 9 }
}
(Bryant Robey, Shea O. Rutstein, and Leo Morros:  The fertility decline in
developing countries, @I { Scientific American }, December 1993.)  Once
again each bar goes from one y value to the next, with its x value
equal to the x value lying between the two y values; this time the very
first x value has no effect on the result.
@PP
The colour of one set of data can be changed with a @Code "colour"
option:
@ID @OneRow @Code {
"@Data"
"    colour { blue }"
}
For the complete list of acceptable colour names, see Section
{@NumberOf colour}.  The @Code "colour" option's name may also be
spelt @Code {"color"}.
@PP
It is also possible to paint the area between the data points and
the x axis (or frame if @Code "style" is not {@Code "axes"}), using
@ID @OneRow @Code {
"@Data"
"    paint { yes }"
}
The paint colour is determined by the @Code "colour" option just
introduced; it will be @Code "black" if no colour is specified.  Paint
(including white paint) hides paint, points, and lines drawn by previous
data sets.  However the points and lines of each data set are drawn after
painting that set, so they cannot be hidden under their own paint; and
axes and frames are drawn last so that they too are never hidden.
@PP
A @Code "dataformat" option is provided for changing the interpretation
dataformat. @Index { @Code "dataformat" option in graphs }
of the data.  Ordinarily, as we know, the numbers are taken to be pairs of
x and y coordinates, like this:
@ID @OneRow @Code {
"@Data"
"{"
"    x y  x y  ...  x y"
"}"
}
However, by setting @Code "dataformat" to {@Code "yonly"}, the
interpretation is changed to a sequence of y coordinates only:
@ID @OneRow @Code {
"@Data"
"    dataformat { yonly }"
"{"
"    y y  ...  y"
"}"
}
and x values 1, 2, and so on are inserted automatically, just as though
the original input had been
@ID @OneRow @Code {
"@Data"
"{"
"    1 y  2 y  ..."
"}"
}
There is also {@Code "xonly"}, which inserts y values 1, 2, and so on.  The
default value, {@Code "xandy"}, gives the usual interpretation.  The
layout of data on lines has no effect on the interpretation.
@End @Section