Enable the show value labels feature
[pspp] / tests / language / stats / graph.at
1 AT_BANNER([GRAPH])
2
3 AT_SETUP([GRAPH simple scatterplot])
4 AT_DATA([scatterplot.sps],[
5 * Simple Scatterplot test
6 NEW FILE.
7 INPUT PROGRAM.
8 LOOP #i = 1 to 100.
9 COMPUTE Age = RV.NORMAL(40,10).
10 END CASE.
11 END LOOP.
12 END FILE.
13 END INPUT PROGRAM.
14
15 COMPUTE Size = Age * 3 + 50.
16
17 GRAPH
18     /SCATTERPLOT(BIVARIATE) = Age WITH Size. 
19
20 ])
21
22 AT_CHECK([pspp -O format=csv scatterplot.sps], [0], [ignore])
23
24 AT_CLEANUP
25
26
27 AT_SETUP([GRAPH Scatter and Histogram])
28 AT_DATA([scatterlong.sps],[
29 NEW FILE.
30 INPUT PROGRAM.
31 LOOP #i = 1 to 10000.
32 COMPUTE Age = RV.NORMAL(40,10).
33 COMPUTE CityNum = TRUNC(UNIFORM(2.95)).
34 END CASE.
35 END LOOP.
36 END FILE.
37 END INPUT PROGRAM.
38
39 COMPUTE Size = Age * 3 + 50 + 50*CityNum.
40
41 STRING City (a20).
42
43 Recode CityNum 
44        (0 = "Madrid")
45        (1 = "Paris")
46        (ELSE = "Stockholm")
47        into City.
48
49  GRAPH
50     /SCATTERPLOT(BIVARIATE) = Age WITH Size 
51
52  GRAPH
53     /SCATTERPLOT(BIVARIATE) = Age WITH CityNum
54  
55  GRAPH
56     /SCATTERPLOT = CityNum WITH Age
57
58  GRAPH
59     /SCATTERPLOT = CityNum WITH Size
60
61  GRAPH
62     /SCATTERPLOT(BIVARIATE) = Age WITH Size BY City
63
64  GRAPH
65     /SCATTERPLOT(BIVARIATE) = Age WITH Size BY CityNum
66
67  ADD VALUE LABELS 
68     /CityNum 1 'Rio' 2 'Tokyo' 0 'Mumbai'.
69
70  GRAPH
71     /SCATTERPLOT(BIVARIATE) = Age WITH Size BY CityNum
72
73  GRAPH
74     /HISTOGRAM = Age.
75
76 ])
77
78 AT_CHECK([pspp -O format=pdf scatterlong.sps], [0], [ignore])
79 AT_CLEANUP
80
81 AT_SETUP([GRAPH missing values don't crash])
82 AT_DATA([scatter.sps], [dnl
83 data list list /x * y *.
84 begin data.
85 1 0
86 2 0
87 . 0
88 3 1
89 4 1
90 5 .
91 6 1
92 end data.
93 graph 
94       /scatterplot = x with y.
95 graph
96       /histogram = x. 
97 ])
98 AT_CHECK([pspp -o pspp.pdf scatter.sps])
99 dnl Ignore output -- this is just a no-crash check.
100 AT_CLEANUP
101
102 AT_SETUP([GRAPH missing=VARIABLE no crash])
103 AT_DATA([scatter.sps], [dnl
104 data list list /x * y *.
105 begin data.
106 1 0
107 2 0
108 . 0
109 3 1
110 4 1
111 5 .
112 6 1
113 end data.
114 graph 
115       /scatterplot = x with y
116       /missing = VARIABLE.
117 graph
118       /histogram = x
119       /missing = VARIABLE.
120 ])
121 AT_CHECK([pspp -o pspp.pdf scatter.sps])
122 dnl Ignore output -- this is just a no-crash check.
123 AT_CLEANUP
124
125 AT_SETUP([GRAPH missing value in by variable])
126 AT_DATA([scatter.sps], [dnl
127 data list list /x * y * z *.
128 begin data.
129 1 0 9
130 2 0 9
131 . 0 9
132 3 1 .
133 4 1 8
134 5 . 8
135 6 1 8
136 end data.
137 graph 
138       /scatterplot = x with y by z
139       /missing = VARIABLE.
140
141 graph 
142       /scatterplot = x with y by z.
143
144 ])
145 AT_CHECK([pspp -o pspp.pdf scatter.sps])
146 dnl Ignore output -- this is just a no-crash check.
147 AT_CLEANUP
148
149
150 AT_SETUP([GRAPH histogram with null data])
151 AT_DATA([null-hist.sps], [dnl
152 data list list /x *.
153 begin data.
154 1109 
155
156 end data.
157
158 graph 
159       /histogram = x.
160
161 ])
162
163 AT_CHECK([pspp -o pspp.pdf null-hist.sps], [0], [ignore])
164 dnl Ignore output -- this is just a no-crash check.
165 AT_CLEANUP
166
167
168 AT_SETUP([GRAPH histogram all missing])
169 AT_DATA([null-hist.sps], [dnl
170 data list list /x *.
171 begin data.
172
173 end data.
174
175 graph 
176       /histogram = x.
177
178 ])
179
180 AT_CHECK([pspp null-hist.sps], [0], [ignore])
181 dnl Ignore output -- this is just a no-crash check.
182 AT_CLEANUP
183
184
185
186
187 AT_SETUP([GRAPH barcharts])
188 AT_CHECK([ln -s $top_srcdir/examples/physiology.sav .], [0])
189 AT_CHECK([ln -s $top_srcdir/examples/repairs.sav .], [0])
190
191 AT_DATA([barchart.sps], [dnl
192 GET FILE="physiology.sav".
193
194 GRAPH /BAR = COUNT BY SEX.
195
196 GRAPH /BAR = MEAN(height) BY SEX.
197
198 NEW FILE.
199
200 GET FILE="repairs.sav".
201
202 GRAPH /BAR = MEAN (mtbf) BY factory.
203
204 COMPUTE  R = TRUNC(RV.UNIFORM(1,5)).
205
206 GRAPH /BAR = MEAN (mtbf) BY factory BY R.
207 ])
208
209 AT_CHECK([pspp -o pspp.pdf barchart.sps], [0], [ignore])
210 dnl Ignore output -- this is just a no-crash check.
211
212 AT_CLEANUP
213
214
215
216 AT_SETUP([GRAPH barchart arity])
217
218 AT_DATA([barchart.sps], [dnl
219 data list notable list /x y z*.
220 begin data
221 1  1  3
222 2  1  4
223 3  1  3
224 4  1  4
225 5  .  3
226 6  2  4
227 7  2  3
228 8  2  4
229 9  2  3
230 10  2  4
231 end data.
232
233 * This line is invalid
234 GRAPH /BAR = COUNT(x) BY y.
235 ])
236
237 AT_CHECK([pspp -o pspp.pdf barchart.sps], [1], [ignore])
238 dnl Ignore output -- this is just a no-crash check.
239
240 AT_CLEANUP
241
242
243
244
245 AT_SETUP([GRAPH barchart bad syntax])
246
247 AT_DATA([barchart.sps], [dnl
248 data list notable list /x y z*.
249 begin data
250 1  1  3
251 2  1  4
252 3  1  3
253 4  1  4
254 5  .  3
255 6  2  4
256 7  2  3
257 8  2  4
258 9  2  3
259 10  2  4
260 end data.
261
262 * This line is invalid
263 GRAPH /BAR = SCROD BY y.
264 ])
265
266 AT_CHECK([pspp -o pspp.pdf barchart.sps], [1], [ignore])
267 dnl Ignore output -- this is just a no-crash check.
268
269 AT_CLEANUP
270
271
272
273 AT_SETUP([GRAPH barchart full])
274
275 AT_DATA([barchart.sps], [dnl
276 data list notable list /x y z*.
277 begin data
278 1  1  3
279 2  1  4
280 3  1  3
281 4  1  4
282 5  .  3
283 6  2  4
284 7  2  3
285 8  2  4
286 9  2  3
287 10  2  4
288 end data.
289
290 * This line is invalid
291 GRAPH /BAR = COUNT by z.
292 GRAPH /BAR = CUFREQ by z.
293 GRAPH /BAR = PCT by z.
294 GRAPH /BAR = CUPCT by z.
295
296 GRAPH /BAR = MEAN(y) BY z.
297 GRAPH /BAR = SUM(y) BY z.
298 GRAPH /BAR = MAXIMUM(y) BY z.
299 GRAPH /BAR = MINIMUM(y) BY z.
300
301 GRAPH /BAR = MEAN(y) BY z BY y.
302 GRAPH /BAR = SUM(y) BY z BY y.
303 GRAPH /BAR = MAXIMUM(y) BY z BY y.
304 GRAPH /BAR = MINIMUM(y) BY z BY y.
305 ])
306
307 AT_CHECK([pspp -o pspp.pdf barchart.sps], [0], [ignore])
308 dnl Ignore output -- this is just a no-crash check.
309
310 AT_CLEANUP
311
312
313
314
315
316 AT_SETUP([GRAPH buggy syntax])
317
318 AT_DATA([barchart.sps], [dnl
319 data list notable list /x y z*.
320 begin data
321 1  1  3
322 2  1  4
323 10  2  4
324 end data.
325
326 GRAPH /BAR = MINIMUM({) BY z BY y.
327 ])
328
329 AT_CHECK([pspp -o pspp.pdf barchart.sps], [1], [ignore])
330 dnl Ignore output -- this is just a no-crash check.
331
332 AT_CLEANUP