comparison scripts/plot/__go_draw_axes__.m @ 7316:fac781a4078d

[project @ 2007-12-14 17:32:25 by jwe]
author jwe
date Fri, 14 Dec 2007 17:32:25 +0000
parents 28a9e3d3bf14
children 11c5f1ee553e
comparison
equal deleted inserted replaced
7315:3ceb12c499e9 7316:fac781a4078d
280 zautoscale = strcmpi (axis_obj.zlimmode, "auto"); 280 zautoscale = strcmpi (axis_obj.zlimmode, "auto");
281 cautoscale = strcmpi (axis_obj.climmode, "auto"); 281 cautoscale = strcmpi (axis_obj.climmode, "auto");
282 282
283 kids = axis_obj.children; 283 kids = axis_obj.children;
284 284
285 nd = 0; 285 nd = __calc_dimensions__ (axis_obj);
286
287 if (nd == 3)
288 fputs (plot_stream, "set parametric;\n");
289 fputs (plot_stream, "set style data lines;\n");
290 fputs (plot_stream, "set surface;\n");
291 fputs (plot_stream, "unset contour;\n");
292 endif
293
286 data_idx = 0; 294 data_idx = 0;
287 data = cell (); 295 data = cell ();
288 is_image_data = []; 296 is_image_data = [];
289 hidden_removal = NaN; 297 hidden_removal = NaN;
290 view_map = false; 298 view_map = false;
309 317
310 obj = get (kids(i)); 318 obj = get (kids(i));
311 319
312 switch (obj.type) 320 switch (obj.type)
313 case "image" 321 case "image"
314 ## FIXME - Is there a better way to determine if the plot
315 ## command should be "plot" or "splot"????? Could have images
316 ## projected into 3D so there is really no reason to limit
317 ## this.
318 if (nd == 0)
319 nd = 2;
320 endif
321
322 img_data = obj.cdata; 322 img_data = obj.cdata;
323 img_xdata = obj.xdata; 323 img_xdata = obj.xdata;
324 img_ydata = obj.ydata; 324 img_ydata = obj.ydata;
325 325
326 if (use_gnuplot_for_images) 326 if (use_gnuplot_for_images)
389 style, data_idx); 389 style, data_idx);
390 else 390 else
391 withclause{data_idx} = sprintf ("with %s linetype %d", 391 withclause{data_idx} = sprintf ("with %s linetype %d",
392 style, typ); 392 style, typ);
393 endif 393 endif
394 if (! isempty (obj.zdata)) 394 if (nd == 3)
395 nd = 3;
396 xdat = obj.xdata(:); 395 xdat = obj.xdata(:);
397 ydat = obj.ydata(:); 396 ydat = obj.ydata(:);
398 zdat = obj.zdata(:); 397 if (! isempty (obj.zdata))
399 398 zdat = obj.zdata(:);
399 else
400 zdat = zeros (size (xdat));
401 endif
400 data{data_idx} = [xdat, ydat, zdat]'; 402 data{data_idx} = [xdat, ydat, zdat]';
401 usingclause{data_idx} = "using ($1):($2):($3)"; 403 usingclause{data_idx} = "using ($1):($2):($3)";
402 fputs (plot_stream, "set parametric;\n"); 404 ## fputs (plot_stream, "set parametric;\n");
403 fputs (plot_stream, "set style data lines;\n");
404 fputs (plot_stream, "set surface;\n");
405 fputs (plot_stream, "unset contour;\n");
406 else 405 else
407 nd = 2;
408 xdat = obj.xdata(:); 406 xdat = obj.xdata(:);
409 ydat = obj.ydata(:); 407 ydat = obj.ydata(:);
410 ldat = obj.ldata; 408 ldat = obj.ldata;
411 yerr = xerr = false; 409 yerr = xerr = false;
412 if (! isempty (ldat)) 410 if (! isempty (ldat))
496 endif 494 endif
497 495
498 for i = 1:nc 496 for i = 1:nc
499 xcol = obj.xdata(:,i); 497 xcol = obj.xdata(:,i);
500 ycol = obj.ydata(:,i); 498 ycol = obj.ydata(:,i);
501 if (! isempty (obj.zdata)) 499 if (nd == 3)
502 zcol = obj.zdata(:,i); 500 if (! isempty (obj.zdata))
503 else 501 zcol = obj.zdata(:,i);
504 zcol = []; 502 else
503 zcol = zeros (size (xcol));
504 endif
505 endif 505 endif
506 506
507 if (! isnan (xcol) && ! isnan (ycol)) 507 if (! isnan (xcol) && ! isnan (ycol))
508 ## Is the patch closed or not 508 ## Is the patch closed or not
509 if (strncmp (obj.facecolor, "none", 4)) 509 if (strncmp (obj.facecolor, "none", 4))
510 if (isnan (hidden_removal)) 510 if (isnan (hidden_removal))
511 hidden_removal = false; 511 hidden_removal = false;
512 endif 512 endif
513 else 513 else
514 hidden_removal = true; 514 hidden_removal = true;
515 if (! isempty (zcol)) 515 if (nd == 3)
516 error ("gnuplot (as of v4.2) only supports 2D filled patches"); 516 error ("gnuplot (as of v4.2) only supports 2D filled patches");
517 else
518 nd = 2;
519 endif 517 endif
520 518
521 data_idx++; 519 data_idx++;
522 is_image_data(data_idx) = false; 520 is_image_data(data_idx) = false;
523 parametric(data_idx) = false; 521 parametric(data_idx) = false;
608 endif 606 endif
609 endif 607 endif
610 608
611 ## patch outline 609 ## patch outline
612 if (! strncmp (obj.edgecolor, "none", 4)) 610 if (! strncmp (obj.edgecolor, "none", 4))
613 if (! isempty (zcol))
614 nd = 3;
615 else
616 nd = 2;
617 endif
618 611
619 data_idx++; 612 data_idx++;
620 is_image_data(data_idx) = false; 613 is_image_data(data_idx) = false;
621 parametric(data_idx) = false; 614 parametric(data_idx) = false;
622 have_cdata(data_idx) = false; 615 have_cdata(data_idx) = false;
787 endif 780 endif
788 withclause{data_idx} = sprintf ("with %s %s %s lt %d", 781 withclause{data_idx} = sprintf ("with %s %s %s lt %d",
789 style, pt, ps, typ); 782 style, pt, ps, typ);
790 endif 783 endif
791 784
792 if (! isempty (zcol)) 785 if (nd == 3)
793 if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol)) 786 if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol))
794 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ... 787 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ...
795 [zcol; zcol(1)]]'; 788 [zcol; zcol(1)]]';
796 else 789 else
797 data{data_idx} = [xcol, ycol, zcol]'; 790 data{data_idx} = [xcol, ycol, zcol]';
807 endif 800 endif
808 endif 801 endif
809 endfor 802 endfor
810 803
811 case "surface" 804 case "surface"
812 nd = 3;
813 view_map = true; 805 view_map = true;
814 if (! (strncmp (obj.edgecolor, "none", 4) 806 if (! (strncmp (obj.edgecolor, "none", 4)
815 && strncmp (obj.facecolor, "none", 4))) 807 && strncmp (obj.facecolor, "none", 4)))
816 data_idx++; 808 data_idx++;
817 is_image_data(data_idx) = false; 809 is_image_data(data_idx) = false;
875 k++; 867 k++;
876 endfor 868 endfor
877 data{data_idx} = zz.'; 869 data{data_idx} = zz.';
878 endif 870 endif
879 usingclause{data_idx} = "using ($1):($2):($3):($4)"; 871 usingclause{data_idx} = "using ($1):($2):($3):($4)";
880 872 ## fputs (plot_stream, "unset parametric;\n");
881 fputs (plot_stream, "unset parametric;\n");
882 fputs (plot_stream, "set style data lines;\n");
883 fputs (plot_stream, "set surface;\n");
884 fputs (plot_stream, "unset contour;\n");
885 873
886 ## Interpolation does not work for flat surfaces (e.g. pcolor) 874 ## Interpolation does not work for flat surfaces (e.g. pcolor)
887 ## and color mapping --> currently set empty. 875 ## and color mapping --> currently set empty.
888 interp_str = ""; 876 interp_str = "";
889 flat_interp_face = (strncmp (obj.facecolor, "flat", 4) 877 flat_interp_face = (strncmp (obj.facecolor, "flat", 4)
1389 fputs (plot_stream, " default"); 1377 fputs (plot_stream, " default");
1390 endif 1378 endif
1391 1379
1392 fputs (plot_stream, ";\n"); 1380 fputs (plot_stream, ";\n");
1393 1381
1382 endfunction
1383
1384 function nd = __calc_dimensions__ (obj)
1385 kids = obj.children;
1386 nd = 2;
1387 for i = 1:length (kids)
1388 obj = get (kids(i));
1389 switch (obj.type)
1390 case {"image", "text"}
1391 ## ignore as they
1392 case {"line", "patch"}
1393 if (! isempty (obj.zdata))
1394 nd = 3;
1395 endif
1396 case "surface"
1397 nd = 3;
1398 endswitch
1399 endfor
1394 endfunction 1400 endfunction
1395 1401
1396 function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata) 1402 function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata)
1397 1403
1398 ## DATA is already transposed. 1404 ## DATA is already transposed.