comparison scripts/plot/plot3.m @ 10549:95c3e38098bf

Untabify .m scripts
author Rik <code@nomad.inbox5.com>
date Fri, 23 Apr 2010 11:28:50 -0700
parents 4516a0c97ced
children e81914f3921f
comparison
equal deleted inserted replaced
10548:479536c5bb10 10549:95c3e38098bf
110 continue; 110 continue;
111 endif 111 endif
112 112
113 if (ischar (new)) 113 if (ischar (new))
114 if (! z_set) 114 if (! z_set)
115 if (! y_set) 115 if (! y_set)
116 if (! x_set) 116 if (! x_set)
117 error ("plot3: needs x, [ y, [ z ] ]"); 117 error ("plot3: needs x, [ y, [ z ] ]");
118 else 118 else
119 z = imag (x); 119 z = imag (x);
120 y = real (x); 120 y = real (x);
121 y_set = 1; 121 y_set = 1;
122 z_set = 1; 122 z_set = 1;
123 if (rows(x) > 1) 123 if (rows(x) > 1)
124 x = repmat ((1:rows(x))', 1, columns(x)); 124 x = repmat ((1:rows(x))', 1, columns(x));
125 else 125 else
126 x = 1:columns(x); 126 x = 1:columns(x);
127 endif 127 endif
128 endif 128 endif
129 else 129 else
130 z = imag (y); 130 z = imag (y);
131 y = real (y); 131 y = real (y);
132 z_set = 1; 132 z_set = 1;
133 endif 133 endif
134 endif 134 endif
135 135
136 if (! fmt_set) 136 if (! fmt_set)
137 [options, valid] = __pltopt__ ("plot3", new, false); 137 [options, valid] = __pltopt__ ("plot3", new, false);
138 if (! valid) 138 if (! valid)
139 properties = [properties, new_cell]; 139 properties = [properties, new_cell];
140 property_set = 1; 140 property_set = 1;
141 continue; 141 continue;
142 else 142 else
143 fmt_set = 1; 143 fmt_set = 1;
144 while (arg < nargin && ischar (varargin{arg+1})) 144 while (arg < nargin && ischar (varargin{arg+1}))
145 if (nargin - arg < 2) 145 if (nargin - arg < 2)
146 error ("plot3: properties must appear followed by a value"); 146 error ("plot3: properties must appear followed by a value");
147 endif 147 endif
148 properties = [properties, varargin(arg+1:arg+2)]; 148 properties = [properties, varargin(arg+1:arg+2)];
149 arg += 2; 149 arg += 2;
150 endwhile 150 endwhile
151 endif 151 endif
152 else 152 else
153 properties = [properties, new_cell]; 153 properties = [properties, new_cell];
154 property_set = 1; 154 property_set = 1;
155 continue; 155 continue;
156 endif 156 endif
157 157
158 if (isvector (x) && isvector (y)) 158 if (isvector (x) && isvector (y))
159 if (isvector (z)) 159 if (isvector (z))
160 x = x(:); 160 x = x(:);
161 y = y(:); 161 y = y(:);
162 z = z(:); 162 z = z(:);
163 elseif (length (x) == rows (z) && length (y) == columns (z)) 163 elseif (length (x) == rows (z) && length (y) == columns (z))
164 [x, y] = meshgrid (x, y); 164 [x, y] = meshgrid (x, y);
165 else 165 else
166 error ("plot3: [length(x), length(y)] must match size(z)"); 166 error ("plot3: [length(x), length(y)] must match size(z)");
167 endif 167 endif
168 endif 168 endif
169 169
170 if (! size_equal (x, y, z)) 170 if (! size_equal (x, y, z))
171 error ("plot3: x, y, and z must have the same shape"); 171 error ("plot3: x, y, and z must have the same shape");
172 endif 172 endif
173 173
174 key = options.key; 174 key = options.key;
175 if (! isempty (key)) 175 if (! isempty (key))
176 set (gca (), "key", "on"); 176 set (gca (), "key", "on");
177 endif 177 endif
178 178
179 for i = 1 : columns (x) 179 for i = 1 : columns (x)
180 linestyle = options.linestyle; 180 linestyle = options.linestyle;
181 marker = options.marker; 181 marker = options.marker;
182 if (isempty (marker) && isempty (linestyle)) 182 if (isempty (marker) && isempty (linestyle))
183 [linestyle, marker] = __next_line_style__ (); 183 [linestyle, marker] = __next_line_style__ ();
184 endif 184 endif
185 color = options.color; 185 color = options.color;
186 if (isempty (options.color)) 186 if (isempty (options.color))
187 color = __next_line_color__ (); 187 color = __next_line_color__ ();
188 endif 188 endif
189 189
190 tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key, 190 tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key,
191 "color", color, "linestyle", linestyle, 191 "color", color, "linestyle", linestyle,
192 "marker", marker, properties{:}); 192 "marker", marker, properties{:});
193 endfor 193 endfor
194 194
195 x_set = 0; 195 x_set = 0;
196 y_set = 0; 196 y_set = 0;
197 z_set = 0; 197 z_set = 0;
206 elseif (! z_set) 206 elseif (! z_set)
207 z = new; 207 z = new;
208 z_set = 1; 208 z_set = 1;
209 else 209 else
210 if (isvector (x) && isvector (y)) 210 if (isvector (x) && isvector (y))
211 if (isvector (z)) 211 if (isvector (z))
212 x = x(:); 212 x = x(:);
213 y = y(:); 213 y = y(:);
214 z = z(:); 214 z = z(:);
215 elseif (length (x) == rows (z) && length (y) == columns (z)) 215 elseif (length (x) == rows (z) && length (y) == columns (z))
216 [x, y] = meshgrid (x, y); 216 [x, y] = meshgrid (x, y);
217 else 217 else
218 error ("plot3: [length(x), length(y)] must match size(z)"); 218 error ("plot3: [length(x), length(y)] must match size(z)");
219 endif 219 endif
220 endif 220 endif
221 221
222 if (! size_equal (x, y, z)) 222 if (! size_equal (x, y, z))
223 error ("plot3: x, y, and z must have the same shape"); 223 error ("plot3: x, y, and z must have the same shape");
224 endif 224 endif
225 225
226 options = __default_plot_options__ (); 226 options = __default_plot_options__ ();
227 key = options.key; 227 key = options.key;
228 if (! isempty (key)) 228 if (! isempty (key))
229 set (gca (), "key", "on"); 229 set (gca (), "key", "on");
230 endif 230 endif
231 231
232 for i = 1 : columns (x) 232 for i = 1 : columns (x)
233 linestyle = options.linestyle; 233 linestyle = options.linestyle;
234 marker = options.marker; 234 marker = options.marker;
235 if (isempty (marker) && isempty (linestyle)) 235 if (isempty (marker) && isempty (linestyle))
236 [linestyle, marker] = __next_line_style__ (); 236 [linestyle, marker] = __next_line_style__ ();
237 endif 237 endif
238 color = options.color; 238 color = options.color;
239 if (isempty (color)) 239 if (isempty (color))
240 color = __next_line_color__ (); 240 color = __next_line_color__ ();
241 endif 241 endif
242 242
243 tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key, 243 tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key,
244 "color", color, "linestyle", linestyle, 244 "color", color, "linestyle", linestyle,
245 "marker", marker, properties{:}); 245 "marker", marker, properties{:});
246 endfor 246 endfor
247 247
248 x = new; 248 x = new;
249 y_set = 0; 249 y_set = 0;
250 z_set = 0; 250 z_set = 0;
261 ## Handle last plot. 261 ## Handle last plot.
262 262
263 if (x_set) 263 if (x_set)
264 if (y_set) 264 if (y_set)
265 if (! z_set) 265 if (! z_set)
266 z = imag (y); 266 z = imag (y);
267 y = real (y); 267 y = real (y);
268 z_set = 1; 268 z_set = 1;
269 endif 269 endif
270 else 270 else
271 z = imag (x); 271 z = imag (x);
272 y = real (x); 272 y = real (x);
273 y_set = 1; 273 y_set = 1;
274 z_set = 1; 274 z_set = 1;
275 if (rows (x) > 1) 275 if (rows (x) > 1)
276 x = repmat ((1:rows (x))', 1, columns(x)); 276 x = repmat ((1:rows (x))', 1, columns(x));
277 else 277 else
278 x = 1:columns(x); 278 x = 1:columns(x);
279 endif 279 endif
280 endif 280 endif
281 281
282 if (isvector (x) && isvector (y)) 282 if (isvector (x) && isvector (y))
283 if (isvector (z)) 283 if (isvector (z))
284 x = x(:); 284 x = x(:);
285 y = y(:); 285 y = y(:);
286 z = z(:); 286 z = z(:);
287 elseif (length (x) == rows (z) && length (y) == columns (z)) 287 elseif (length (x) == rows (z) && length (y) == columns (z))
288 [x, y] = meshgrid (x, y); 288 [x, y] = meshgrid (x, y);
289 else 289 else
290 error ("plot3: [length(x), length(y)] must match size(z)"); 290 error ("plot3: [length(x), length(y)] must match size(z)");
291 endif 291 endif
292 endif 292 endif
293 293
294 if (! size_equal (x, y, z)) 294 if (! size_equal (x, y, z))
295 error ("plot3: x, y, and z must have the same shape"); 295 error ("plot3: x, y, and z must have the same shape");
303 303
304 for i = 1 : columns (x) 304 for i = 1 : columns (x)
305 linestyle = options.linestyle; 305 linestyle = options.linestyle;
306 marker = options.marker; 306 marker = options.marker;
307 if (isempty (marker) && isempty (linestyle)) 307 if (isempty (marker) && isempty (linestyle))
308 [linestyle, marker] = __next_line_style__ (); 308 [linestyle, marker] = __next_line_style__ ();
309 endif 309 endif
310 color = options.color; 310 color = options.color;
311 if (isempty (color)) 311 if (isempty (color))
312 color = __next_line_color__ (); 312 color = __next_line_color__ ();
313 endif 313 endif
314 314
315 tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key, 315 tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key,
316 "color", color, "linestyle", linestyle, 316 "color", color, "linestyle", linestyle,
317 "marker", marker, properties{:}); 317 "marker", marker, properties{:});
318 endfor 318 endfor
319 endif 319 endif
320 320
321 set (gca (), "view", [-37.5, 30]); 321 set (gca (), "view", [-37.5, 30]);
322 322