comparison scripts/plot/__go_draw_axes__.m @ 8218:8a5fbd656f55

make previous change work for surface plots
author Daniel J. Sebald <daniel.sebald@ieee.org>
date Wed, 15 Oct 2008 10:51:59 -0400
parents f74cb5e3a6c1
children 4e05ba66ead2
comparison
equal deleted inserted replaced
8217:f74cb5e3a6c1 8218:8a5fbd656f55
380 titlespec{data_idx} = "title \"\""; 380 titlespec{data_idx} = "title \"\"";
381 else 381 else
382 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel")); 382 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel"));
383 titlespec{data_idx} = cstrcat ("title \"", tmp, "\""); 383 titlespec{data_idx} = cstrcat ("title \"", tmp, "\"");
384 endif 384 endif
385 usingclause{data_idx} = ""; 385 usingclause{data_idx} = sprintf ("record=%d", numel (obj.xdata));
386 errbars = ""; 386 errbars = "";
387 if (nd == 3) 387 if (nd == 3)
388 xdat = obj.xdata(:); 388 xdat = obj.xdata(:);
389 ydat = obj.ydata(:); 389 ydat = obj.ydata(:);
390 if (! isempty (obj.zdata)) 390 if (! isempty (obj.zdata))
391 zdat = obj.zdata(:); 391 zdat = obj.zdata(:);
392 else 392 else
393 zdat = zeros (size (xdat)); 393 zdat = zeros (size (xdat));
394 endif 394 endif
395 data{data_idx} = [xdat, ydat, zdat]'; 395 data{data_idx} = [xdat, ydat, zdat]';
396 usingclause{data_idx} = "using ($1):($2):($3)"; 396 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", numel (xdat));
397 ## fputs (plot_stream, "set parametric;\n"); 397 ## fputs (plot_stream, "set parametric;\n");
398 else 398 else
399 xdat = obj.xdata(:); 399 xdat = obj.xdata(:);
400 ydat = obj.ydata(:); 400 ydat = obj.ydata(:);
401 ldat = obj.ldata; 401 ldat = obj.ldata;
438 xhi = xdat; 438 xhi = xdat;
439 else 439 else
440 xhi = xdat+xudat; 440 xhi = xdat+xudat;
441 endif 441 endif
442 data{data_idx} = [xdat, ydat, xlo, xhi, ylo, yhi]'; 442 data{data_idx} = [xdat, ydat, xlo, xhi, ylo, yhi]';
443 usingclause{data_idx} = "using ($1):($2):($3):($4):($5):($6)"; 443 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3):($4):($5):($6)", numel (xdat));
444 errbars = "xyerrorbars"; 444 errbars = "xyerrorbars";
445 else 445 else
446 data{data_idx} = [xdat, ydat, ylo, yhi]'; 446 data{data_idx} = [xdat, ydat, ylo, yhi]';
447 usingclause{data_idx} = "using ($1):($2):($3):($4)"; 447 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3):($4)", numel (xdat));
448 errbars = "yerrorbars"; 448 errbars = "yerrorbars";
449 endif 449 endif
450 elseif (xerr) 450 elseif (xerr)
451 if (isempty (xldat)) 451 if (isempty (xldat))
452 xlo = xdat; 452 xlo = xdat;
457 xhi = xdat; 457 xhi = xdat;
458 else 458 else
459 xhi = xdat+xudat; 459 xhi = xdat+xudat;
460 endif 460 endif
461 data{data_idx} = [xdat, ydat, xlo, xhi]'; 461 data{data_idx} = [xdat, ydat, xlo, xhi]';
462 usingclause{data_idx} = "using ($1):($2):($3):($4)"; 462 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3):($4)", numel (xdat));
463 errbars = "xerrorbars"; 463 errbars = "xerrorbars";
464 else 464 else
465 data{data_idx} = [xdat, ydat]'; 465 data{data_idx} = [xdat, ydat]';
466 usingclause{data_idx} = sprintf ("using ($1):($2) axes %s%s", 466 usingclause{data_idx} = sprintf ("record=%d using ($1):($2) axes %s%s",
467 xaxisloc_using, yaxisloc_using); 467 rows(xdat), xaxisloc_using, yaxisloc_using);
468 endif 468 endif
469 endif 469 endif
470 470
471 [style, typ, with] = do_linestyle_command (obj, data_idx, mono, 471 [style, typ, with] = do_linestyle_command (obj, data_idx, mono,
472 plot_stream, errbars); 472 plot_stream, errbars);
518 titlespec{data_idx} = "title \"\""; 518 titlespec{data_idx} = "title \"\"";
519 else 519 else
520 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel")); 520 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel"));
521 titlespec{data_idx} = cstrcat ("title \"", tmp, "\""); 521 titlespec{data_idx} = cstrcat ("title \"", tmp, "\"");
522 endif 522 endif
523 usingclause{data_idx} = "";
524 if (isfield (obj, "facecolor")) 523 if (isfield (obj, "facecolor"))
525 if ((strncmp (obj.facecolor, "flat", 4) 524 if ((strncmp (obj.facecolor, "flat", 4)
526 || strncmp (obj.facecolor, "interp", 6)) 525 || strncmp (obj.facecolor, "interp", 6))
527 && isfield (obj, "cdata")) 526 && isfield (obj, "cdata"))
528 if (ndims (obj.cdata) == 2 527 if (ndims (obj.cdata) == 2
571 round (255*color)); 570 round (255*color));
572 endif 571 endif
573 withclause{data_idx} = sprintf ("with filledcurve %s", 572 withclause{data_idx} = sprintf ("with filledcurve %s",
574 colorspec); 573 colorspec);
575 data{data_idx} = [xcol, ycol]'; 574 data{data_idx} = [xcol, ycol]';
576 usingclause{data_idx} = "using ($1):($2)"; 575 usingclause{data_idx} = sprintf ("record=%d using ($1):($2)", numel (xcol));
577 endif 576 endif
578 endif 577 endif
579 578
580 ## patch outline 579 ## patch outline
581 if (! strncmp (obj.edgecolor, "none", 4)) 580 if (! strncmp (obj.edgecolor, "none", 4))
583 data_idx++; 582 data_idx++;
584 is_image_data(data_idx) = false; 583 is_image_data(data_idx) = false;
585 parametric(data_idx) = false; 584 parametric(data_idx) = false;
586 have_cdata(data_idx) = false; 585 have_cdata(data_idx) = false;
587 titlespec{data_idx} = "title \"\""; 586 titlespec{data_idx} = "title \"\"";
588 usingclause{data_idx} = ""; 587 usingclause{data_idx} = sprintf ("record=%d", numel (obj.xdata));
589 588
590 if (isfield (obj, "markersize")) 589 if (isfield (obj, "markersize"))
591 mdat = obj.markersize / 6; 590 mdat = obj.markersize / 6;
592 endif 591 endif
593 592
737 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ... 736 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ...
738 [zcol; zcol(1)]]'; 737 [zcol; zcol(1)]]';
739 else 738 else
740 data{data_idx} = [xcol, ycol, zcol]'; 739 data{data_idx} = [xcol, ycol, zcol]';
741 endif 740 endif
742 usingclause{data_idx} = "using ($1):($2):($3)"; 741 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", columns (data{data_idx}));
743 else 742 else
744 if (! isnan (xcol) && ! isnan (ycol)) 743 if (! isnan (xcol) && ! isnan (ycol))
745 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)]]'; 744 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)]]';
746 else 745 else
747 data{data_idx} = [xcol, ycol]'; 746 data{data_idx} = [xcol, ycol]';
748 endif 747 endif
749 usingclause{data_idx} = "using ($1):($2)"; 748 usingclause{data_idx} = sprintf ("record=%d using ($1):($2)", columns (data{data_idx}));
750 endif 749 endif
751 endif 750 endif
752 endfor 751 endfor
753 752
754 case "surface" 753 case "surface"
765 titlespec{data_idx} = "title \"\""; 764 titlespec{data_idx} = "title \"\"";
766 else 765 else
767 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel")); 766 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel"));
768 titlespec{data_idx} = cstrcat ("title \"", tmp, "\""); 767 titlespec{data_idx} = cstrcat ("title \"", tmp, "\"");
769 endif 768 endif
770 usingclause{data_idx} = "";
771 withclause{data_idx} = sprintf ("with pm3d linestyle %d", 769 withclause{data_idx} = sprintf ("with pm3d linestyle %d",
772 data_idx); 770 data_idx);
773 771
774 xdat = obj.xdata; 772 xdat = obj.xdata;
775 ydat = obj.ydata; 773 ydat = obj.ydata;
818 interp_str = "interpolate 4, 4"; 816 interp_str = "interpolate 4, 4";
819 else 817 else
820 ## No interpolation of facecolors. 818 ## No interpolation of facecolors.
821 interp_str = ""; 819 interp_str = "";
822 endif 820 endif
823 usingclause{data_idx} = "using ($1):($2):($3):($4)"; 821 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3):($4)", xlen, ylen);
824 822
825 flat_interp_face = (strncmp (obj.facecolor, "flat", 4) 823 flat_interp_face = (strncmp (obj.facecolor, "flat", 4)
826 || strncmp (obj.facecolor, "interp", 6)); 824 || strncmp (obj.facecolor, "interp", 6));
827 flat_interp_edge = (strncmp (obj.edgecolor, "flat", 4) 825 flat_interp_edge = (strncmp (obj.edgecolor, "flat", 4)
828 || strncmp (obj.edgecolor, "interp", 6)); 826 || strncmp (obj.edgecolor, "interp", 6));
1142 fputs (plot_stream, "set view map;\n"); 1140 fputs (plot_stream, "set view map;\n");
1143 else 1141 else
1144 fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z); 1142 fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z);
1145 endif 1143 endif
1146 endif 1144 endif
1147 fprintf (plot_stream, "%s \"-\" binary record=%d format='%%float64' %s %s %s \\\n", plot_cmd, 1145 fprintf (plot_stream, "%s \"-\" binary format='%%float64' %s %s %s \\\n", plot_cmd,
1148 columns(data{1}), usingclause{1}, titlespec{1}, withclause{1}); 1146 usingclause{1}, titlespec{1}, withclause{1});
1149 for i = 2:data_idx 1147 for i = 2:data_idx
1150 fprintf (plot_stream, ", \"-\" binary record=%d format='%%float64' %s %s %s \\\n", 1148 fprintf (plot_stream, ", \"-\" binary format='%%float64' %s %s %s \\\n",
1151 columns(data{i}), usingclause{i}, titlespec{i}, withclause{i}); 1149 usingclause{i}, titlespec{i}, withclause{i});
1152 endfor 1150 endfor
1153 fputs (plot_stream, ";\n"); 1151 fputs (plot_stream, ";\n");
1154 for i = 1:data_idx 1152 for i = 1:data_idx
1155 if (is_image_data(i)) 1153 if (is_image_data(i))
1156 fwrite (plot_stream, data{i}, "float32"); 1154 fwrite (plot_stream, data{i}, "float32");