[graphics] fix barhomogenize.tst & bug_13180.tst (surf)
[scilab.git] / scilab / modules / graphics / tests / unit_tests / barhomogenize.tst
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7 //
8 // <-- TEST WITH GRAPHIC -->
9 // <-- NO CHECK REF -->
10
11 // Unit test for barhomogenize
12
13 subplot(2,3,1);
14 xtitle("ex1: creation of 1 yellow bar and  3 bars");
15 x=1:3; y1=1:3; y2=[4 3 5;6 7 8;9 10 11];
16 bar(x,y1,"yellow");bar(x,y2);
17
18 subplot(2,3,2);
19 xtitle("grouped homogenization");
20 x=1:3; y1=1:3; y2=[4 3 5;6 7 8;9 10 11];
21 bar(x,y1,"yellow");bar(x,y2);
22 barhomogenize();
23
24 subplot(2,3,3);
25 xtitle("stacked homogenization");
26 x=1:3; y1=1:3; y2=[4 3 5;6 7 8;9 10 11];
27 bar(x,y1,"yellow");bar(x,y2);
28 barhomogenize("stacked",1);
29
30 f=gcf();
31 a1=f.children(1);
32 a2=f.children(2);
33 a3=f.children(3);
34 c11=a1.children(1);
35 c12=a1.children(2);
36 c21=a2.children(1);
37 c22=a2.children(2);
38 c31=a3.children(1);
39 c32=a3.children(2);
40 // Third graphic: stacked
41 p111=c11.children(1); // red polyline
42 p112=c11.children(2); // green polyline
43 p113=c11.children(3); // blue polyline
44 p121=c12.children(1); // yellow polyline
45 // Second graphic: grouped
46 p211=c21.children(1); // red polyline
47 p212=c21.children(2); // green polyline
48 p213=c21.children(3); // blue polyline
49 p221=c22.children(1); // yellow polyline
50 // First graphic: no homogenized
51 p311=c31.children(1); // red polyline
52 p312=c31.children(2); // green polyline
53 p313=c31.children(3); // blue polyline
54 p321=c32.children(1); // yellow polyline
55
56
57 // Check First graphic axes
58 assert_checkequal(a3.x_location, "bottom");
59 assert_checkequal(a3.y_location, "left");
60 assert_checkequal(a3.auto_ticks, ["off", "on", "on"]);
61 assert_checkequal(a3.x_ticks.locations, [1;2;3]);
62 assert_checkequal(a3.y_ticks.locations, [0;2;4;6;8;10;12]);
63 assert_checkequal(a3.z_ticks.locations, []);
64 assert_checkequal(a3.x_ticks.labels, ["1";"2";"3"]);
65 assert_checkequal(a3.y_ticks.labels, ["0";"2";"4";"6";"8";"10";"12"]);
66 assert_checkequal(a3.z_ticks.labels, []);
67 assert_checkequal(a3.sub_ticks, [0,1]);
68 assert_checktrue(abs(a3.data_bounds - [0.55,0;3.45,11]) < 0.05);
69 assert_checkequal(a3.margins(2:$), [0.125,0.125,0.125]);
70 assert_checktrue(abs(a3.axes_bounds - [0,0,0.3333333333,0.5]) < 0.0005);
71
72 // Check Second
73 assert_checkequal(a2.x_location, a3.x_location);
74 assert_checkequal(a2.y_location, a3.y_location);
75 assert_checkequal(a2.auto_ticks, a3.auto_ticks);
76 assert_checkequal(a2.x_ticks.locations, a3.x_ticks.locations);
77 assert_checkequal(a2.y_ticks.locations, a3.y_ticks.locations);
78 assert_checkequal(a2.z_ticks.locations, a3.z_ticks.locations);
79 assert_checkequal(a2.x_ticks.labels, a3.x_ticks.labels);
80 assert_checkequal(a2.y_ticks.labels, a3.y_ticks.labels);
81 assert_checkequal(a2.z_ticks.labels, a3.z_ticks.labels);
82 assert_checkequal(a2.sub_ticks, a3.sub_ticks);
83 assert_checktrue(abs(a2.data_bounds - a3.data_bounds) < 0.05);
84 assert_checkequal(a2.margins, a3.margins);
85 assert_checktrue(abs(a2.axes_bounds - a3.axes_bounds) < 0.5);
86
87 // Check third
88 assert_checkequal(a1.x_location, a3.x_location);
89 assert_checkequal(a1.y_location, a3.y_location);
90 assert_checkequal(a1.auto_ticks, a3.auto_ticks);
91 assert_checkequal(a1.x_ticks.locations, a3.x_ticks.locations);
92 assert_checkequal(a1.y_ticks.locations, [0;10;20;30]);
93 assert_checkequal(a1.z_ticks.locations, a3.z_ticks.locations);
94 assert_checkequal(a1.x_ticks.labels, a3.x_ticks.labels);
95 assert_checkequal(a1.y_ticks.labels, ["0";"10";"20";"30"]);
96 assert_checkequal(a1.z_ticks.labels, a3.z_ticks.labels);
97 assert_checkequal(a1.sub_ticks, a3.sub_ticks);
98 assert_checktrue(abs(a1.data_bounds - [0.55,0;3.45,33]) < 0.05);
99 m = a3.margins; m(1) = 0.13537;
100 assert_checktrue(abs(a1.margins - m) < 0.005);
101 assert_checktrue(abs(a1.axes_bounds - [0.6666667,0,0.3333333,0.5]) < 0.05);
102
103 // Check polylines of first graphic
104 assert_checkequal(p311.data, [1,5;2,8;3,11]);
105 assert_checkequal(p311.line_style, 1);
106 assert_checkequal(p311.polyline_style, 6);
107 assert_checkequal(p311.foreground, -1);
108 assert_checkequal(p311.background, 5);
109 assert_checkequal(p311.mark_mode, "off");
110 assert_checkequal(p311.mark_style, 0);
111 assert_checkequal(p311.mark_size_unit, "point");
112 assert_checkequal(p311.mark_size, 0);
113 assert_checkequal(p311.mark_foreground, -1);
114 assert_checkequal(p311.mark_background, -2);
115 assert_checkequal(p311.x_shift, [0.7,0.7,0.7]/3);
116 assert_checkequal(p311.y_shift, []);
117 assert_checkalmostequal(p311.bar_width, 0.56/3);
118
119 assert_checkequal(p312.data, [1,3;2,7;3,10]);
120 assert_checkequal(p312.line_style, 1);
121 assert_checkequal(p312.polyline_style, 6);
122 assert_checkequal(p312.foreground, -1);
123 assert_checkequal(p312.background, 33);
124 assert_checkequal(p312.mark_mode, "off");
125 assert_checkequal(p312.mark_style, 0);
126 assert_checkequal(p312.mark_size_unit, "point");
127 assert_checkequal(p312.mark_size, 0);
128 assert_checkequal(p312.mark_foreground, -1);
129 assert_checkequal(p312.mark_background, -2);
130 assert_checkequal(p312.x_shift, [0,0,0]);
131 assert_checkequal(p312.y_shift, []);
132 assert_checkalmostequal(p312.bar_width, 0.56/3);
133
134 assert_checkequal(p313.data, [1,4;2,6;3,9]);
135 assert_checkequal(p313.line_style, 1);
136 assert_checkequal(p313.polyline_style, 6);
137 assert_checkequal(p313.foreground, -1);
138 assert_checkequal(p313.background, 2);
139 assert_checkequal(p313.mark_mode, "off");
140 assert_checkequal(p313.mark_style, 0);
141 assert_checkequal(p313.mark_size_unit, "point");
142 assert_checkequal(p313.mark_size, 0);
143 assert_checkequal(p313.mark_foreground, -1);
144 assert_checkequal(p313.mark_background, -2);
145 assert_checkequal(p313.x_shift, -0.7*[1 1 1]/3);
146 assert_checkequal(p313.y_shift, []);
147 assert_checkalmostequal(p313.bar_width, 0.56/3);
148
149 assert_checkequal(p321.data, [1,1;2,2;3,3]);
150 assert_checkequal(p321.line_style, 1);
151 assert_checkequal(p321.polyline_style, 6);
152 assert_checkequal(p321.foreground, -1);
153 assert_checkequal(p321.background, 7);
154 assert_checkequal(p321.mark_mode, "off");
155 assert_checkequal(p321.mark_style, 0);
156 assert_checkequal(p321.mark_size_unit, "point");
157 assert_checkequal(p321.mark_size, 0);
158 assert_checkequal(p321.mark_foreground, -1);
159 assert_checkequal(p321.mark_background, -2);
160 assert_checkequal(p321.x_shift, [0,0,0]);
161 assert_checkequal(p321.y_shift, []);
162 assert_checkalmostequal(p321.bar_width, 0.8);
163
164 // Check polylines of second graphic
165 assert_checkequal(p211.data, p311.data);
166 assert_checkequal(p211.line_style, p311.line_style);
167 assert_checkequal(p211.polyline_style, p311.polyline_style);
168 assert_checkequal(p211.foreground, p311.foreground);
169 assert_checkequal(p211.background, p311.background);
170 assert_checkequal(p211.mark_mode, p311.mark_mode);
171 assert_checkequal(p211.mark_style, p311.mark_style);
172 assert_checkequal(p211.mark_size_unit, p311.mark_size_unit);
173 assert_checkequal(p211.mark_size, p311.mark_size);
174 assert_checkequal(p211.mark_foreground, p311.mark_foreground);
175 assert_checkequal(p211.mark_background, p311.mark_background);
176 assert_checkequal(p211.x_shift, [-0.3375,-0.3375,-0.3375]);
177 assert_checkequal(p211.y_shift, [0,0,0]);
178 assert_checkalmostequal(p211.bar_width, 0.18);
179
180 assert_checkequal(p212.data, p312.data);
181 assert_checkequal(p212.line_style, p312.line_style);
182 assert_checkequal(p212.polyline_style, p312.polyline_style);
183 assert_checkequal(p212.foreground, p312.foreground);
184 assert_checkequal(p212.background, p312.background);
185 assert_checkequal(p212.mark_mode, p312.mark_mode);
186 assert_checkequal(p212.mark_style, p312.mark_style);
187 assert_checkequal(p212.mark_size_unit, p312.mark_size_unit);
188 assert_checkequal(p212.mark_size, p312.mark_size);
189 assert_checkequal(p212.mark_foreground, p312.mark_foreground);
190 assert_checkequal(p212.mark_background, p312.mark_background);
191 assert_checkequal(p212.x_shift, [-0.1125,-0.1125,-0.1125]);
192 assert_checkequal(p212.y_shift, p211.y_shift);
193 assert_checkalmostequal(p212.bar_width, p211.bar_width);
194
195 assert_checkequal(p213.data, p313.data);
196 assert_checkequal(p213.line_style, p313.line_style);
197 assert_checkequal(p213.polyline_style, p313.polyline_style);
198 assert_checkequal(p213.foreground, p313.foreground);
199 assert_checkequal(p213.background, p313.background);
200 assert_checkequal(p213.mark_mode, p313.mark_mode);
201 assert_checkequal(p213.mark_style, p313.mark_style);
202 assert_checkequal(p213.mark_size_unit, p313.mark_size_unit);
203 assert_checkequal(p213.mark_size, p313.mark_size);
204 assert_checkequal(p213.mark_foreground, p313.mark_foreground);
205 assert_checkequal(p213.mark_background, p313.mark_background);
206 assert_checkequal(p213.x_shift, [0.1125,0.1125,0.1125]);
207 assert_checkequal(p213.y_shift, p211.y_shift);
208 assert_checkalmostequal(p213.bar_width, p211.bar_width);
209
210 assert_checkequal(p221.data, p321.data);
211 assert_checkequal(p221.line_style, p321.line_style);
212 assert_checkequal(p221.polyline_style, p321.polyline_style);
213 assert_checkequal(p221.foreground, p321.foreground);
214 assert_checkequal(p221.background, p321.background);
215 assert_checkequal(p221.mark_mode, p321.mark_mode);
216 assert_checkequal(p221.mark_style, p321.mark_style);
217 assert_checkequal(p221.mark_size_unit, p321.mark_size_unit);
218 assert_checkequal(p221.mark_size, p321.mark_size);
219 assert_checkequal(p221.mark_foreground, p321.mark_foreground);
220 assert_checkequal(p221.mark_background, p321.mark_background);
221 assert_checkequal(p221.x_shift, [0.3375,0.3375,0.3375]);
222 assert_checkequal(p221.y_shift, p211.y_shift);
223 assert_checkalmostequal(p221.bar_width, p211.bar_width);
224
225 // Check polylines of third graphic
226 assert_checkequal(p111.data, p311.data);
227 assert_checkequal(p111.line_style, p311.line_style);
228 assert_checkequal(p111.polyline_style, p311.polyline_style);
229 assert_checkequal(p111.foreground, p311.foreground);
230 assert_checkequal(p111.background, p311.background);
231 assert_checkequal(p111.mark_mode, p311.mark_mode);
232 assert_checkequal(p111.mark_style, p311.mark_style);
233 assert_checkequal(p111.mark_size_unit, p311.mark_size_unit);
234 assert_checkequal(p111.mark_size, p311.mark_size);
235 assert_checkequal(p111.mark_foreground, p311.mark_foreground);
236 assert_checkequal(p111.mark_background, p311.mark_background);
237 assert_checkequal(p111.x_shift, [0,0,0]);
238 assert_checkequal(p111.y_shift, [0,0,0]);
239 assert_checkalmostequal(p111.bar_width, 0.9);
240
241 assert_checkequal(p112.data, p312.data);
242 assert_checkequal(p112.line_style, p312.line_style);
243 assert_checkequal(p112.polyline_style, p312.polyline_style);
244 assert_checkequal(p112.foreground, p312.foreground);
245 assert_checkequal(p112.background, p312.background);
246 assert_checkequal(p112.mark_mode, p312.mark_mode);
247 assert_checkequal(p112.mark_style, p312.mark_style);
248 assert_checkequal(p112.mark_size_unit, p312.mark_size_unit);
249 assert_checkequal(p112.mark_size, p312.mark_size);
250 assert_checkequal(p112.mark_foreground, p312.mark_foreground);
251 assert_checkequal(p112.mark_background, p312.mark_background);
252 assert_checkequal(p112.x_shift, [0,0,0]);
253 assert_checkequal(p112.y_shift, [5,8,11]);
254 assert_checkalmostequal(p112.bar_width, p111.bar_width);
255
256 assert_checkequal(p113.data, p313.data);
257 assert_checkequal(p113.line_style, p313.line_style);
258 assert_checkequal(p113.polyline_style, p313.polyline_style);
259 assert_checkequal(p113.foreground, p313.foreground);
260 assert_checkequal(p113.background, p313.background);
261 assert_checkequal(p113.mark_mode, p313.mark_mode);
262 assert_checkequal(p113.mark_style, p313.mark_style);
263 assert_checkequal(p113.mark_size_unit, p313.mark_size_unit);
264 assert_checkequal(p113.mark_size, p313.mark_size);
265 assert_checkequal(p113.mark_foreground, p313.mark_foreground);
266 assert_checkequal(p113.mark_background, p313.mark_background);
267 assert_checkequal(p113.x_shift, [0,0,0]);
268 assert_checkequal(p113.y_shift, [8,15,21]);
269 assert_checkalmostequal(p113.bar_width, p111.bar_width);
270
271 assert_checkequal(p121.data, p321.data);
272 assert_checkequal(p121.line_style, p321.line_style);
273 assert_checkequal(p121.polyline_style, p321.polyline_style);
274 assert_checkequal(p121.foreground, p321.foreground);
275 assert_checkequal(p121.background, p321.background);
276 assert_checkequal(p121.mark_mode, p321.mark_mode);
277 assert_checkequal(p121.mark_style, p321.mark_style);
278 assert_checkequal(p121.mark_size_unit, p321.mark_size_unit);
279 assert_checkequal(p121.mark_size, p321.mark_size);
280 assert_checkequal(p121.mark_foreground, p321.mark_foreground);
281 assert_checkequal(p121.mark_background, p321.mark_background);
282 assert_checkequal(p121.x_shift, [0,0,0]);
283 assert_checkequal(p121.y_shift, [12,21,30]);
284 assert_checkalmostequal(p121.bar_width, p111.bar_width);