comparison scripts/plot/__go_draw_axes__.m @ 11587:c792872f8942

all script files: untabify and strip trailing whitespace
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:35:29 -0500
parents beb4f0f27a32
children b0084095098e
comparison
equal deleted inserted replaced
11586:12df7854fa7c 11587:c792872f8942
21 ## Undocumented internal function. 21 ## Undocumented internal function.
22 ## @end deftypefn 22 ## @end deftypefn
23 23
24 ## Author: jwe 24 ## Author: jwe
25 25
26 function __go_draw_axes__ (h, plot_stream, enhanced, mono, 26 function __go_draw_axes__ (h, plot_stream, enhanced, mono,
27 bg_is_set, fg_is_set, hlgnd) 27 bg_is_set, fg_is_set, hlgnd)
28 28
29 if (nargin >= 4 && nargin <= 7) 29 if (nargin >= 4 && nargin <= 7)
30 30
31 showhiddenhandles = get (0, "showhiddenhandles"); 31 showhiddenhandles = get (0, "showhiddenhandles");
46 ymirror = true; 46 ymirror = true;
47 endif 47 endif
48 48
49 nd = __calc_dimensions__ (h); 49 nd = __calc_dimensions__ (h);
50 50
51 if (strcmp (axis_obj.dataaspectratiomode, "manual") 51 if (strcmp (axis_obj.dataaspectratiomode, "manual")
52 && strcmp (axis_obj.xlimmode, "manual") 52 && strcmp (axis_obj.xlimmode, "manual")
53 && strcmp (axis_obj.ylimmode, "manual")) 53 && strcmp (axis_obj.ylimmode, "manual"))
54 ## All can't be "manual" 54 ## All can't be "manual"
55 axis_obj.plotboxaspectratiomode = "auto"; 55 axis_obj.plotboxaspectratiomode = "auto";
56 endif 56 endif
104 if (nd == 3 && all (axis_obj.view == [0, 90])) 104 if (nd == 3 && all (axis_obj.view == [0, 90]))
105 ## FIXME -- Kludge to allow colorbar to be added to a pcolor() plot 105 ## FIXME -- Kludge to allow colorbar to be added to a pcolor() plot
106 pos(3:4) = pos(3:4) * 1.4; 106 pos(3:4) = pos(3:4) * 1.4;
107 pos(1:2) = pos(1:2) - pos(3:4) * 0.125; 107 pos(1:2) = pos(1:2) - pos(3:4) * 0.125;
108 endif 108 endif
109 109
110 fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2)); 110 fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2));
111 111
112 if (strcmpi (axis_obj.dataaspectratiomode, "manual")) 112 if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
113 sz_str = sprintf ("set size ratio %.15g", -dr); 113 sz_str = sprintf ("set size ratio %.15g", -dr);
114 else 114 else
115 sz_str = "set size noratio"; 115 sz_str = "set size noratio";
116 endif 116 endif
523 data{data_idx} = [xdat, ydat]'; 523 data{data_idx} = [xdat, ydat]';
524 usingclause{data_idx} = sprintf ("record=%d using ($1):($2) axes %s%s", 524 usingclause{data_idx} = sprintf ("record=%d using ($1):($2) axes %s%s",
525 rows(xdat), xaxisloc_using, yaxisloc_using); 525 rows(xdat), xaxisloc_using, yaxisloc_using);
526 endif 526 endif
527 527
528 style = do_linestyle_command (obj, obj.color, data_idx, mono, 528 style = do_linestyle_command (obj, obj.color, data_idx, mono,
529 plot_stream, errbars); 529 plot_stream, errbars);
530 530
531 withclause{data_idx} = sprintf ("with %s linestyle %d", 531 withclause{data_idx} = sprintf ("with %s linestyle %d",
532 style{1}, data_idx); 532 style{1}, data_idx);
533 533
534 if (length (style) > 1) 534 if (length (style) > 1)
535 data_idx++; 535 data_idx++;
536 is_image_data(data_idx) = is_image_data(data_idx - 1); 536 is_image_data(data_idx) = is_image_data(data_idx - 1);
537 parametric(data_idx) = parametric(data_idx - 1); 537 parametric(data_idx) = parametric(data_idx - 1);
538 have_cdata(data_idx) = have_cdata(data_idx - 1); 538 have_cdata(data_idx) = have_cdata(data_idx - 1);
539 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); 539 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
540 titlespec{data_idx} = "title \"\""; 540 titlespec{data_idx} = "title \"\"";
541 usingclause{data_idx} = usingclause{data_idx - 1}; 541 usingclause{data_idx} = usingclause{data_idx - 1};
543 withclause{data_idx} = sprintf ("with %s linestyle %d", 543 withclause{data_idx} = sprintf ("with %s linestyle %d",
544 style{2}, data_idx); 544 style{2}, data_idx);
545 endif 545 endif
546 if (length (style) > 2) 546 if (length (style) > 2)
547 data_idx++; 547 data_idx++;
548 is_image_data(data_idx) = is_image_data(data_idx - 1); 548 is_image_data(data_idx) = is_image_data(data_idx - 1);
549 parametric(data_idx) = parametric(data_idx - 1); 549 parametric(data_idx) = parametric(data_idx - 1);
550 have_cdata(data_idx) = have_cdata(data_idx - 1); 550 have_cdata(data_idx) = have_cdata(data_idx - 1);
551 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); 551 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
552 titlespec{data_idx} = "title \"\""; 552 titlespec{data_idx} = "title \"\"";
553 usingclause{data_idx} = usingclause{data_idx - 1}; 553 usingclause{data_idx} = usingclause{data_idx - 1};
581 endif 581 endif
582 endif 582 endif
583 583
584 if (! isnan (xcol) && ! isnan (ycol)) 584 if (! isnan (xcol) && ! isnan (ycol))
585 ## Is the patch closed or not 585 ## Is the patch closed or not
586 if (strncmp (obj.facecolor, "none", 4)) 586 if (strncmp (obj.facecolor, "none", 4))
587 hidden_removal = false; 587 hidden_removal = false;
588 else 588 else
589 589
590 if (isnan (hidden_removal)) 590 if (isnan (hidden_removal))
591 hidden_removal = true; 591 hidden_removal = true;
594 if (numel (xcol) > 3) 594 if (numel (xcol) > 3)
595 error ("__go_draw_axes__: gnuplot (as of v4.2) only supports 3D filled triangular patches"); 595 error ("__go_draw_axes__: gnuplot (as of v4.2) only supports 3D filled triangular patches");
596 else 596 else
597 if (isnan (data_3d_idx)) 597 if (isnan (data_3d_idx))
598 data_idx++; 598 data_idx++;
599 data_3d_idx = data_idx; 599 data_3d_idx = data_idx;
600 is_image_data(data_idx) = false; 600 is_image_data(data_idx) = false;
601 parametric(data_idx) = false; 601 parametric(data_idx) = false;
602 have_cdata(data_idx) = true; 602 have_cdata(data_idx) = true;
603 have_3d_patch(data_idx) = true; 603 have_3d_patch(data_idx) = true;
604 withclause{data_3d_idx} = sprintf ("with pm3d"); 604 withclause{data_3d_idx} = sprintf ("with pm3d");
655 endif 655 endif
656 elseif (strncmp (obj.facecolor, "interp", 6)) 656 elseif (strncmp (obj.facecolor, "interp", 6))
657 if (nd == 3 && numel (xcol) == 3) 657 if (nd == 3 && numel (xcol) == 3)
658 ccdat = ccol; 658 ccdat = ccol;
659 if (! isvector (ccdat)) 659 if (! isvector (ccdat))
660 tmp = rows(cmap) + rows(addedcmap) + ... 660 tmp = rows(cmap) + rows(addedcmap) + ...
661 [1 : rows(ccdat)]; 661 [1 : rows(ccdat)];
662 addedcmap = [addedcmap; ccdat]; 662 addedcmap = [addedcmap; ccdat];
663 ccdat = tmp(:); 663 ccdat = tmp(:);
664 else 664 else
665 ccdat = ccdat(:); 665 ccdat = ccdat(:);
709 endif 709 endif
710 endif 710 endif
711 711
712 ## patch outline 712 ## patch outline
713 if (!(strncmp (obj.edgecolor, "none", 4) 713 if (!(strncmp (obj.edgecolor, "none", 4)
714 && (strncmp (obj.marker, "none", 4) 714 && (strncmp (obj.marker, "none", 4)
715 || (strncmp (obj.markeredgecolor, "none", 4) 715 || (strncmp (obj.markeredgecolor, "none", 4)
716 && strncmp (obj.markerfacecolor, "none", 4))))) 716 && strncmp (obj.markerfacecolor, "none", 4)))))
717 717
718 data_idx++; 718 data_idx++;
719 is_image_data(data_idx) = false; 719 is_image_data(data_idx) = false;
844 style = "lines"; 844 style = "lines";
845 endif 845 endif
846 tmpwith = {}; 846 tmpwith = {};
847 847
848 facesame = true; 848 facesame = true;
849 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") 849 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor")
850 && !strncmp (obj.markerfacecolor, "none", 4)) 850 && !strncmp (obj.markerfacecolor, "none", 4))
851 if (strncmp (obj.markerfacecolor, "auto", 4) 851 if (strncmp (obj.markerfacecolor, "auto", 4)
852 || ! isnumeric (obj.markerfacecolor) 852 || ! isnumeric (obj.markerfacecolor)
853 || (isnumeric (obj.markerfacecolor) 853 || (isnumeric (obj.markerfacecolor)
854 && isequal (color, obj.markerfacecolor))) 854 && isequal (color, obj.markerfacecolor)))
855 style = strcat (style, "points"); 855 style = strcat (style, "points");
856 if (isfield (obj, "markersize")) 856 if (isfield (obj, "markersize"))
857 if (length (mdat) == nc) 857 if (length (mdat) == nc)
858 m = mdat(i); 858 m = mdat(i);
863 else 863 else
864 ps = ""; 864 ps = "";
865 endif 865 endif
866 866
867 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s", 867 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
868 style, lw, pt2, lt, ps, 868 style, lw, pt2, lt, ps,
869 colorspec); 869 colorspec);
870 else 870 else
871 facesame = false; 871 facesame = false;
872 if (! isempty (style)) 872 if (! isempty (style))
873 tmpwith{sidx} = sprintf ("with %s %s %s %s", 873 tmpwith{sidx} = sprintf ("with %s %s %s %s",
874 style, lw, lt, 874 style, lw, lt,
875 colorspec); 875 colorspec);
876 sidx ++; 876 sidx ++;
877 endif 877 endif
878 if (isnumeric (obj.markerfacecolor) && ! mono) 878 if (isnumeric (obj.markerfacecolor) && ! mono)
879 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", 879 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
889 ps = sprintf("pointsize %f", m / 3); 889 ps = sprintf("pointsize %f", m / 3);
890 else 890 else
891 ps = ""; 891 ps = "";
892 endif 892 endif
893 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s", 893 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
894 style, lw, pt2, lt, ps, 894 style, lw, pt2, lt, ps,
895 colorspec); 895 colorspec);
896 endif 896 endif
897 endif 897 endif
898 898
899 if (isfield (obj, "markeredgecolor") 899 if (isfield (obj, "markeredgecolor")
900 && !strncmp (obj.markeredgecolor, "none", 4)) 900 && !strncmp (obj.markeredgecolor, "none", 4))
901 if (facesame && !isempty (pt) 901 if (facesame && !isempty (pt)
902 && (strncmp (obj.markeredgecolor, "auto", 4) 902 && (strncmp (obj.markeredgecolor, "auto", 4)
903 || ! isnumeric (obj.markeredgecolor) 903 || ! isnumeric (obj.markeredgecolor)
904 || (isnumeric (obj.markeredgecolor) 904 || (isnumeric (obj.markeredgecolor)
905 && isequal (color, obj.markeredgecolor)))) 905 && isequal (color, obj.markeredgecolor))))
906 if (sidx == 1 && ((length (style) == 5 906 if (sidx == 1 && ((length (style) == 5
907 && strncmp (style, "lines", 5)) 907 && strncmp (style, "lines", 5))
908 || isempty (style))) 908 || isempty (style)))
909 style = strcat (style, "points"); 909 style = strcat (style, "points");
910 if (isfield (obj, "markersize")) 910 if (isfield (obj, "markersize"))
911 if (length (mdat) == nc) 911 if (length (mdat) == nc)
912 m = mdat(i); 912 m = mdat(i);
916 ps = sprintf("pointsize %f", m / 3); 916 ps = sprintf("pointsize %f", m / 3);
917 else 917 else
918 ps = ""; 918 ps = "";
919 endif 919 endif
920 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s", 920 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
921 style, lw, pt, lt, ps, 921 style, lw, pt, lt, ps,
922 colorspec); 922 colorspec);
923 endif 923 endif
924 else 924 else
925 if (!isempty (style)) 925 if (!isempty (style))
926 if (length(tmpwith) < sidx || isempty (tmpwith{sidx})) 926 if (length(tmpwith) < sidx || isempty (tmpwith{sidx}))
927 tmpwith{sidx} = sprintf ("with %s %s %s %s", 927 tmpwith{sidx} = sprintf ("with %s %s %s %s",
928 style, lw, lt, 928 style, lw, lt,
929 colorspec); 929 colorspec);
930 endif 930 endif
931 sidx ++; 931 sidx ++;
932 endif 932 endif
933 933
934 if (!isempty (pt)) 934 if (!isempty (pt))
935 if (! mono) 935 if (! mono)
936 if (strncmp (obj.markeredgecolor, "auto", 4)) 936 if (strncmp (obj.markeredgecolor, "auto", 4))
937 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", 937 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
938 round (255*color)); 938 round (255*color));
939 elseif (isnumeric (obj.markeredgecolor) && ! mono) 939 elseif (isnumeric (obj.markeredgecolor) && ! mono)
951 ps = sprintf("pointsize %f", m / 3); 951 ps = sprintf("pointsize %f", m / 3);
952 else 952 else
953 ps = ""; 953 ps = "";
954 endif 954 endif
955 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s", 955 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
956 style, lw, pt, lt, ps, 956 style, lw, pt, lt, ps,
957 colorspec); 957 colorspec);
958 endif 958 endif
959 endif 959 endif
960 endif 960 endif
961 961
962 if (isempty (tmpwith)) 962 if (isempty (tmpwith))
963 withclause{data_idx} = sprintf ("with %s %s %s %s %s", 963 withclause{data_idx} = sprintf ("with %s %s %s %s %s",
964 style, lw, pt, lt, 964 style, lw, pt, lt,
965 colorspec); 965 colorspec);
966 else 966 else
967 withclause{data_idx} = tmpwith{1}; 967 withclause{data_idx} = tmpwith{1};
968 endif 968 endif
969 if (nd == 3) 969 if (nd == 3)
1003 endif 1003 endif
1004 endif 1004 endif
1005 1005
1006 if (length (tmpwith) > 1) 1006 if (length (tmpwith) > 1)
1007 data_idx++; 1007 data_idx++;
1008 is_image_data(data_idx) = is_image_data(data_idx - 1); 1008 is_image_data(data_idx) = is_image_data(data_idx - 1);
1009 parametric(data_idx) = parametric(data_idx - 1); 1009 parametric(data_idx) = parametric(data_idx - 1);
1010 have_cdata(data_idx) = have_cdata(data_idx - 1); 1010 have_cdata(data_idx) = have_cdata(data_idx - 1);
1011 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); 1011 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
1012 titlespec{data_idx} = "title \"\""; 1012 titlespec{data_idx} = "title \"\"";
1013 usingclause{data_idx} = usingclause{data_idx - 1}; 1013 usingclause{data_idx} = usingclause{data_idx - 1};
1014 data{data_idx} = data{data_idx - 1}; 1014 data{data_idx} = data{data_idx - 1};
1015 withclause{data_idx} = tmpwith{2}; 1015 withclause{data_idx} = tmpwith{2};
1016 endif 1016 endif
1017 if (length (tmpwith) > 2) 1017 if (length (tmpwith) > 2)
1018 data_idx++; 1018 data_idx++;
1019 is_image_data(data_idx) = is_image_data(data_idx - 1); 1019 is_image_data(data_idx) = is_image_data(data_idx - 1);
1020 parametric(data_idx) = parametric(data_idx - 1); 1020 parametric(data_idx) = parametric(data_idx - 1);
1021 have_cdata(data_idx) = have_cdata(data_idx - 1); 1021 have_cdata(data_idx) = have_cdata(data_idx - 1);
1022 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); 1022 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
1023 titlespec{data_idx} = "title \"\""; 1023 titlespec{data_idx} = "title \"\"";
1024 usingclause{data_idx} = usingclause{data_idx - 1}; 1024 usingclause{data_idx} = usingclause{data_idx - 1};
1036 is_image_data(data_idx) = false; 1036 is_image_data(data_idx) = false;
1037 parametric(data_idx) = false; 1037 parametric(data_idx) = false;
1038 have_cdata(data_idx) = true; 1038 have_cdata(data_idx) = true;
1039 have_3d_patch(data_idx) = false; 1039 have_3d_patch(data_idx) = false;
1040 style = do_linestyle_command (obj, obj.edgecolor, 1040 style = do_linestyle_command (obj, obj.edgecolor,
1041 data_idx, mono, 1041 data_idx, mono,
1042 plot_stream); 1042 plot_stream);
1043 1043
1044 if (isempty (obj.displayname)) 1044 if (isempty (obj.displayname))
1045 titlespec{data_idx} = "title \"\""; 1045 titlespec{data_idx} = "title \"\"";
1046 else 1046 else
1125 hidden_removal = true; 1125 hidden_removal = true;
1126 endif 1126 endif
1127 fputs(plot_stream,"unset pm3d;\n"); 1127 fputs(plot_stream,"unset pm3d;\n");
1128 fputs(plot_stream,"set style increment user;\n"); 1128 fputs(plot_stream,"set style increment user;\n");
1129 withpm3d = false; 1129 withpm3d = false;
1130 withclause{data_idx} = sprintf("with %s linestyle %d", 1130 withclause{data_idx} = sprintf("with %s linestyle %d",
1131 style{1}, data_idx); 1131 style{1}, data_idx);
1132 fputs (plot_stream, "unset pm3d\n"); 1132 fputs (plot_stream, "unset pm3d\n");
1133 endif 1133 endif
1134 1134
1135 if (doing_interp_color) 1135 if (doing_interp_color)
1138 else 1138 else
1139 dord = "depthorder"; 1139 dord = "depthorder";
1140 endif 1140 endif
1141 1141
1142 if (flat_interp_face && strncmp (obj.edgecolor, "flat", 4)) 1142 if (flat_interp_face && strncmp (obj.edgecolor, "flat", 4))
1143 fprintf (plot_stream, "set pm3d explicit at s %s %s corners2color c3;\n", 1143 fprintf (plot_stream, "set pm3d explicit at s %s %s corners2color c3;\n",
1144 interp_str, dord); 1144 interp_str, dord);
1145 elseif (!facecolor_none_or_white) 1145 elseif (!facecolor_none_or_white)
1146 if (strncmp (obj.edgecolor, "none", 4)) 1146 if (strncmp (obj.edgecolor, "none", 4))
1147 if (__gnuplot_has_feature__ ("transparent_surface") 1147 if (__gnuplot_has_feature__ ("transparent_surface")
1148 && isscalar (obj.facealpha)) 1148 && isscalar (obj.facealpha))
1149 fprintf (plot_stream, 1149 fprintf (plot_stream,
1150 "set style fill transparent solid %f;\n", 1150 "set style fill transparent solid %f;\n",
1151 obj.facealpha); 1151 obj.facealpha);
1152 endif 1152 endif
1153 fprintf (plot_stream, "set pm3d explicit at s %s corners2color c3;\n", 1153 fprintf (plot_stream, "set pm3d explicit at s %s corners2color c3;\n",
1154 interp_str, dord); 1154 interp_str, dord);
1155 else 1155 else
1156 fprintf (plot_stream, "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n", 1156 fprintf (plot_stream, "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n",
1157 data_idx, interp_str, dord); 1157 data_idx, interp_str, dord);
1158 1158
1159 if (__gnuplot_has_feature__ ("transparent_surface") 1159 if (__gnuplot_has_feature__ ("transparent_surface")
1160 && isscalar (obj.facealpha)) 1160 && isscalar (obj.facealpha))
1161 fprintf (plot_stream, 1161 fprintf (plot_stream,
1162 "set style fill transparent solid %f;\n", 1162 "set style fill transparent solid %f;\n",
1163 obj.facealpha); 1163 obj.facealpha);
1164 endif 1164 endif
1165 endif 1165 endif
1166 endif 1166 endif
1167 1167
1168 zz = []; 1168 zz = [];
1169 if (length (style) > 1) 1169 if (length (style) > 1)
1170 len = 3 * xlen; 1170 len = 3 * xlen;
1171 zz = zeros (ylen, len); 1171 zz = zeros (ylen, len);
1172 k = 1; 1172 k = 1;
1177 k++; 1177 k++;
1178 endfor 1178 endfor
1179 zz = zz.'; 1179 zz = zz.';
1180 1180
1181 data_idx++; 1181 data_idx++;
1182 is_image_data(data_idx) = is_image_data(data_idx - 1); 1182 is_image_data(data_idx) = is_image_data(data_idx - 1);
1183 parametric(data_idx) = parametric(data_idx - 1); 1183 parametric(data_idx) = parametric(data_idx - 1);
1184 have_cdata(data_idx) = false; 1184 have_cdata(data_idx) = false;
1185 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); 1185 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
1186 titlespec{data_idx} = "title \"\""; 1186 titlespec{data_idx} = "title \"\"";
1187 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen); 1187 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen);
1190 style{2}, data_idx); 1190 style{2}, data_idx);
1191 1191
1192 endif 1192 endif
1193 if (length (style) > 2) 1193 if (length (style) > 2)
1194 data_idx++; 1194 data_idx++;
1195 is_image_data(data_idx) = is_image_data(data_idx - 1); 1195 is_image_data(data_idx) = is_image_data(data_idx - 1);
1196 parametric(data_idx) = parametric(data_idx - 1); 1196 parametric(data_idx) = parametric(data_idx - 1);
1197 have_cdata(data_idx) = false; 1197 have_cdata(data_idx) = false;
1198 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); 1198 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
1199 titlespec{data_idx} = "title \"\""; 1199 titlespec{data_idx} = "title \"\"";
1200 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen); 1200 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen);
1214 k++; 1214 k++;
1215 endfor 1215 endfor
1216 zz = zz.'; 1216 zz = zz.';
1217 endif 1217 endif
1218 data_idx++; 1218 data_idx++;
1219 is_image_data(data_idx) = is_image_data(data_idx - 1); 1219 is_image_data(data_idx) = is_image_data(data_idx - 1);
1220 parametric(data_idx) = parametric(data_idx - 1); 1220 parametric(data_idx) = parametric(data_idx - 1);
1221 have_cdata(data_idx) = false; 1221 have_cdata(data_idx) = false;
1222 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); 1222 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
1223 titlespec{data_idx} = "title \"\""; 1223 titlespec{data_idx} = "title \"\"";
1224 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen); 1224 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen);
1243 && strcmp (units, "data")) 1243 && strcmp (units, "data"))
1244 units = "second"; 1244 units = "second";
1245 else 1245 else
1246 units = ""; 1246 units = "";
1247 endif 1247 endif
1248 1248
1249 if (isnumeric (color)) 1249 if (isnumeric (color))
1250 colorspec = get_text_colorspec (color, mono); 1250 colorspec = get_text_colorspec (color, mono);
1251 endif 1251 endif
1252 1252
1253 switch valign 1253 switch valign
1352 zdir = "noreverse"; 1352 zdir = "noreverse";
1353 endif 1353 endif
1354 fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir); 1354 fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir);
1355 endif 1355 endif
1356 1356
1357 cmap = parent_figure_obj.colormap; 1357 cmap = parent_figure_obj.colormap;
1358 cmap_sz = rows(cmap); 1358 cmap_sz = rows(cmap);
1359 if (! any (isinf (clim))) 1359 if (! any (isinf (clim)))
1360 if (truecolor || ! cdatadirect) 1360 if (truecolor || ! cdatadirect)
1361 if (rows(addedcmap) > 0) 1361 if (rows(addedcmap) > 0)
1362 for i = 1:data_idx 1362 for i = 1:data_idx
1363 if (have_3d_patch(i)) 1363 if (have_3d_patch(i))
1364 data{i}(end,:) = clim(2) * (data{i}(end, :) - 0.5) / cmap_sz; 1364 data{i}(end,:) = clim(2) * (data{i}(end, :) - 0.5) / cmap_sz;
1365 endif 1365 endif
1366 endfor 1366 endfor
1367 fprintf (plot_stream, "set cbrange [%g:%g];\n", clim(1), clim(2) * 1367 fprintf (plot_stream, "set cbrange [%g:%g];\n", clim(1), clim(2) *
1368 (cmap_sz + rows(addedcmap)) / cmap_sz); 1368 (cmap_sz + rows(addedcmap)) / cmap_sz);
1369 else 1369 else
1370 fprintf (plot_stream, "set cbrange [%g:%g];\n", clim); 1370 fprintf (plot_stream, "set cbrange [%g:%g];\n", clim);
1371 endif 1371 endif
1372 else 1372 else
1373 fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz + 1373 fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz +
1374 rows (addedcmap)); 1374 rows (addedcmap));
1375 endif 1375 endif
1376 endif 1376 endif
1377 1377
1378 if (strcmpi (axis_obj.box, "on")) 1378 if (strcmpi (axis_obj.box, "on"))
1461 pos = "left top"; 1461 pos = "left top";
1462 case "southeast" 1462 case "southeast"
1463 pos = "right bottom"; 1463 pos = "right bottom";
1464 case "southwest" 1464 case "southwest"
1465 pos = "left bottom"; 1465 pos = "left bottom";
1466 case "best" 1466 case "best"
1467 pos = ""; 1467 pos = "";
1468 warning ("legend: 'Best' not yet implemented for location specifier.\n"); 1468 warning ("legend: 'Best' not yet implemented for location specifier.\n");
1469 ## Least conflict with data in plot. 1469 ## Least conflict with data in plot.
1470 ## Least unused space outside plot. 1470 ## Least unused space outside plot.
1471 otherwise 1471 otherwise
1475 [fontname, fontsize] = get_fontname_and_size (obj); 1475 [fontname, fontsize] = get_fontname_and_size (obj);
1476 fontspec = create_fontspec (fontname, fontsize, gnuplot_term); 1476 fontspec = create_fontspec (fontname, fontsize, gnuplot_term);
1477 else 1477 else
1478 fontspec = ""; 1478 fontspec = "";
1479 endif 1479 endif
1480 fprintf (plot_stream, "set key %s %s;\nset key %s %s %s %s;\n", 1480 fprintf (plot_stream, "set key %s %s;\nset key %s %s %s %s;\n",
1481 inout, pos, box, reverse, horzvert, fontspec); 1481 inout, pos, box, reverse, horzvert, fontspec);
1482 else 1482 else
1483 fputs (plot_stream, "unset key;\n"); 1483 fputs (plot_stream, "unset key;\n");
1484 endif 1484 endif
1485 fputs (plot_stream, "set style data lines;\n"); 1485 fputs (plot_stream, "set style data lines;\n");
1532 fprintf (plot_stream, ", \"-\" %s %s %s \\\n", 1532 fprintf (plot_stream, ", \"-\" %s %s %s \\\n",
1533 usingclause{i}, titlespec{i}, withclause{i}); 1533 usingclause{i}, titlespec{i}, withclause{i});
1534 elseif (is_image_data (i)) 1534 elseif (is_image_data (i))
1535 if (! is_image_data (i-1)) 1535 if (! is_image_data (i-1))
1536 fputs (plot_stream, "; "); 1536 fputs (plot_stream, "; ");
1537 if (bg_is_set) 1537 if (bg_is_set)
1538 fputs (plot_stream, "unset obj 1; \\\n"); 1538 fputs (plot_stream, "unset obj 1; \\\n");
1539 bg_is_set = false; 1539 bg_is_set = false;
1540 endif 1540 endif
1541 if (fg_is_set) 1541 if (fg_is_set)
1542 fputs (plot_stream, "unset obj 2; \\\n"); 1542 fputs (plot_stream, "unset obj 2; \\\n");
1544 endif 1544 endif
1545 endif 1545 endif
1546 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, 1546 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd,
1547 usingclause{i}, titlespec{i}, withclause{i}); 1547 usingclause{i}, titlespec{i}, withclause{i});
1548 elseif (is_image_data (i-1)) 1548 elseif (is_image_data (i-1))
1549 if (bg_is_set) 1549 if (bg_is_set)
1550 fputs (plot_stream, "unset obj 1; \\\n"); 1550 fputs (plot_stream, "unset obj 1; \\\n");
1551 bg_is_set = false; 1551 bg_is_set = false;
1552 endif 1552 endif
1553 if (fg_is_set) 1553 if (fg_is_set)
1554 fputs (plot_stream, "unset obj 2; \\\n"); 1554 fputs (plot_stream, "unset obj 2; \\\n");
1562 endif 1562 endif
1563 endfor 1563 endfor
1564 fputs (plot_stream, ";\n"); 1564 fputs (plot_stream, ";\n");
1565 for i = 1:data_idx 1565 for i = 1:data_idx
1566 if (have_3d_patch (i)) 1566 if (have_3d_patch (i))
1567 ## Can't write 3d patch data as binary as can't plot more than 1567 ## Can't write 3d patch data as binary as can't plot more than
1568 ## a single patch at a time and have to plot all patches together 1568 ## a single patch at a time and have to plot all patches together
1569 ## so that the gnuplot depth ordering is done correctly 1569 ## so that the gnuplot depth ordering is done correctly
1570 for j = 1 : 4 : columns(data{i}) 1570 for j = 1 : 4 : columns(data{i})
1571 if (j != 1) 1571 if (j != 1)
1572 fputs (plot_stream, "\n\n"); 1572 fputs (plot_stream, "\n\n");
1578 endfor 1578 endfor
1579 fputs (plot_stream, "e\n"); 1579 fputs (plot_stream, "e\n");
1580 elseif (is_image_data(i)) 1580 elseif (is_image_data(i))
1581 fwrite (plot_stream, data{i}, "float32"); 1581 fwrite (plot_stream, data{i}, "float32");
1582 else 1582 else
1583 __gnuplot_write_data__ (plot_stream, data{i}, nd, parametric(i), 1583 __gnuplot_write_data__ (plot_stream, data{i}, nd, parametric(i),
1584 have_cdata(i)); 1584 have_cdata(i));
1585 endif 1585 endif
1586 endfor 1586 endfor
1587 else 1587 else
1588 fputs (plot_stream, "plot \"-\";\nInf Inf\ne\n"); 1588 fputs (plot_stream, "plot \"-\";\nInf Inf\ne\n");
1590 1590
1591 ## Needed to allow mouse rotation with pcolor. 1591 ## Needed to allow mouse rotation with pcolor.
1592 if (view_map) 1592 if (view_map)
1593 fputs (plot_stream, "unset view;\n"); 1593 fputs (plot_stream, "unset view;\n");
1594 endif 1594 endif
1595 1595
1596 if (bg_is_set) 1596 if (bg_is_set)
1597 fputs (plot_stream, "unset obj 1;\n"); 1597 fputs (plot_stream, "unset obj 1;\n");
1598 bg_is_set = false; 1598 bg_is_set = false;
1599 endif 1599 endif
1600 1600
1601 fflush (plot_stream); 1601 fflush (plot_stream);
1677 else 1677 else
1678 style {sidx} = "lines"; 1678 style {sidx} = "lines";
1679 endif 1679 endif
1680 1680
1681 facesame = true; 1681 facesame = true;
1682 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") 1682 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor")
1683 && !strncmp (obj.markerfacecolor, "none", 4)) 1683 && !strncmp (obj.markerfacecolor, "none", 4))
1684 if (strncmp (obj.markerfacecolor, "auto", 4) 1684 if (strncmp (obj.markerfacecolor, "auto", 4)
1685 || ! isnumeric (obj.markerfacecolor) 1685 || ! isnumeric (obj.markerfacecolor)
1686 || (isnumeric (obj.markerfacecolor) 1686 || (isnumeric (obj.markerfacecolor)
1687 && isequal (color, obj.markerfacecolor))) 1687 && isequal (color, obj.markerfacecolor)))
1688 if (! isempty (pt2)) 1688 if (! isempty (pt2))
1689 fprintf (plot_stream, " pointtype %s", pt2); 1689 fprintf (plot_stream, " pointtype %s", pt2);
1690 style {sidx} = strcat (style{sidx}, "points"); 1690 style {sidx} = strcat (style{sidx}, "points");
1691 endif 1691 endif
1696 facesame = false; 1696 facesame = false;
1697 if (! found_style) 1697 if (! found_style)
1698 fputs (plot_stream, " default"); 1698 fputs (plot_stream, " default");
1699 endif 1699 endif
1700 fputs (plot_stream, ";\n"); 1700 fputs (plot_stream, ";\n");
1701 if (! isempty (style {sidx})) 1701 if (! isempty (style {sidx}))
1702 sidx ++; 1702 sidx ++;
1703 idx ++; 1703 idx ++;
1704 else 1704 else
1705 fputs (plot_stream, ";\n"); 1705 fputs (plot_stream, ";\n");
1706 endif 1706 endif
1717 if (isfield (obj, "markersize")) 1717 if (isfield (obj, "markersize"))
1718 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); 1718 fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
1719 endif 1719 endif
1720 endif 1720 endif
1721 endif 1721 endif
1722 if (isfield (obj, "markeredgecolor") 1722 if (isfield (obj, "markeredgecolor")
1723 && !strncmp (obj.markeredgecolor, "none", 4)) 1723 && !strncmp (obj.markeredgecolor, "none", 4))
1724 if (facesame && !isempty (pt) 1724 if (facesame && !isempty (pt)
1725 && (strncmp (obj.markeredgecolor, "auto", 4) 1725 && (strncmp (obj.markeredgecolor, "auto", 4)
1726 || ! isnumeric (obj.markeredgecolor) 1726 || ! isnumeric (obj.markeredgecolor)
1727 || (isnumeric (obj.markeredgecolor) 1727 || (isnumeric (obj.markeredgecolor)
1728 && isequal (color, obj.markeredgecolor)))) 1728 && isequal (color, obj.markeredgecolor))))
1729 if (sidx == 1 && ((length (style {sidx}) == 5 1729 if (sidx == 1 && ((length (style {sidx}) == 5
1730 && strncmp (style {sidx}, "lines", 5)) || isempty (style {sidx}))) 1730 && strncmp (style {sidx}, "lines", 5)) || isempty (style {sidx})))
1731 if (! isempty (pt)) 1731 if (! isempty (pt))
1732 style {sidx} = strcat (style{sidx}, "points"); 1732 style {sidx} = strcat (style{sidx}, "points");
1733 fprintf (plot_stream, " pointtype %s", pt); 1733 fprintf (plot_stream, " pointtype %s", pt);
1734 endif 1734 endif
1739 else 1739 else
1740 if (! found_style) 1740 if (! found_style)
1741 fputs (plot_stream, " default"); 1741 fputs (plot_stream, " default");
1742 endif 1742 endif
1743 fputs (plot_stream, ";\n"); 1743 fputs (plot_stream, ";\n");
1744 if (!isempty (style {sidx})) 1744 if (!isempty (style {sidx}))
1745 sidx ++; 1745 sidx ++;
1746 idx ++; 1746 idx ++;
1747 else 1747 else
1748 fputs (plot_stream, ";\n"); 1748 fputs (plot_stream, ";\n");
1749 endif 1749 endif
1840 pt = pt2 = ""; 1840 pt = pt2 = "";
1841 endif 1841 endif
1842 endfunction 1842 endfunction
1843 1843
1844 function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata) 1844 function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata)
1845 1845
1846 ## DATA is already transposed. 1846 ## DATA is already transposed.
1847 1847
1848 ## FIXME -- this may need to be converted to C++ for speed. 1848 ## FIXME -- this may need to be converted to C++ for speed.
1849 1849
1850 ## Convert NA elements to normal NaN values because fprintf writes 1850 ## Convert NA elements to normal NaN values because fprintf writes
1992 k = 1; 1992 k = 1;
1993 ntics = numel (tics); 1993 ntics = numel (tics);
1994 nlabels = numel (labels); 1994 nlabels = numel (labels);
1995 fprintf (plot_stream, "set format %s \"%%s\";\n", ax); 1995 fprintf (plot_stream, "set format %s \"%%s\";\n", ax);
1996 if (mirror) 1996 if (mirror)
1997 fprintf (plot_stream, "set %stics %s %s %s mirror (", ax, 1997 fprintf (plot_stream, "set %stics %s %s %s mirror (", ax,
1998 tickdir, ticklength, axispos); 1998 tickdir, ticklength, axispos);
1999 else 1999 else
2000 fprintf (plot_stream, "set %stics %s %s %s nomirror (", ax, 2000 fprintf (plot_stream, "set %stics %s %s %s nomirror (", ax,
2001 tickdir, ticklength, axispos); 2001 tickdir, ticklength, axispos);
2002 endif 2002 endif
2003 2003
2004 labels = regexprep(labels, '%', "%%"); 2004 labels = regexprep(labels, '%', "%%");
2005 for i = 1:ntics 2005 for i = 1:ntics
2006 fprintf (plot_stream, " \"%s\" %.15g", labels{k++}, tics(i)); 2006 fprintf (plot_stream, " \"%s\" %.15g", labels{k++}, tics(i));
2007 if (i < ntics) 2007 if (i < ntics)
2008 fputs (plot_stream, ", "); 2008 fputs (plot_stream, ", ");
2038 endif 2038 endif
2039 endif 2039 endif
2040 else 2040 else
2041 fprintf (plot_stream, "set format %s \"%s\";\n", ax, fmt); 2041 fprintf (plot_stream, "set format %s \"%s\";\n", ax, fmt);
2042 if (mirror) 2042 if (mirror)
2043 fprintf (plot_stream, "set %stics %s %s %s mirror %s %s;\n", ax, 2043 fprintf (plot_stream, "set %stics %s %s %s mirror %s %s;\n", ax,
2044 axispos, tickdir, ticklength, colorspec, fontspec); 2044 axispos, tickdir, ticklength, colorspec, fontspec);
2045 else 2045 else
2046 fprintf (plot_stream, "set %stics %s %s %s nomirror %s %s;\n", ax, 2046 fprintf (plot_stream, "set %stics %s %s %s nomirror %s %s;\n", ax,
2047 tickdir, ticklength, axispos, colorspec, fontspec); 2047 tickdir, ticklength, axispos, colorspec, fontspec);
2048 endif 2048 endif
2049 if (strcmp (mtics, "on")) 2049 if (strcmp (mtics, "on"))
2050 fprintf (plot_stream, "set m%stics %d;\n", ax, num_mtics); 2050 fprintf (plot_stream, "set m%stics %d;\n", ax, num_mtics);
2051 else 2051 else
2172 it = false; 2172 it = false;
2173 str = cstrcat (str(1:s(i) - 1), '/', fnt, ' ', str(s(i) + 3:end)); 2173 str = cstrcat (str(1:s(i) - 1), '/', fnt, ' ', str(s(i) + 3:end));
2174 elseif (strncmp (f, "it", 2) || strncmp (f, "sl", 2)) 2174 elseif (strncmp (f, "it", 2) || strncmp (f, "sl", 2))
2175 it = true; 2175 it = true;
2176 if (bld) 2176 if (bld)
2177 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', 2177 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ',
2178 str(s(i) + 3:end)); 2178 str(s(i) + 3:end));
2179 else 2179 else
2180 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-italic ', 2180 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-italic ',
2181 str(s(i) + 3:end)); 2181 str(s(i) + 3:end));
2182 endif 2182 endif
2183 elseif (strncmp (f, "bf", 2)) 2183 elseif (strncmp (f, "bf", 2))
2184 bld = true; 2184 bld = true;
2185 if (it) 2185 if (it)
2186 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', 2186 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ',
2187 str(2(i) + 3:end)); 2187 str(2(i) + 3:end));
2188 else 2188 else
2189 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bold ', 2189 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bold ',
2190 str(s(i) + 3:end)); 2190 str(s(i) + 3:end));
2191 endif 2191 endif
2192 elseif (strcmpi (f, "color")) 2192 elseif (strcmpi (f, "color"))
2193 ## FIXME Ignore \color but remove trailing {} block as well 2193 ## FIXME Ignore \color but remove trailing {} block as well
2194 d = strfind(str(e(i) + 1:end),'}'); 2194 d = strfind(str(e(i) + 1:end),'}');
2201 b1 = strfind(str(e(i) + 1:end),'{'); 2201 b1 = strfind(str(e(i) + 1:end),'{');
2202 b2 = strfind(str(e(i) + 1:end),'}'); 2202 b2 = strfind(str(e(i) + 1:end),'}');
2203 if (isempty(b1) || isempty(b2)) 2203 if (isempty(b1) || isempty(b2))
2204 warning ('syntax error in \fontname argument'); 2204 warning ('syntax error in \fontname argument');
2205 else 2205 else
2206 str = cstrcat (str(1:s(i) - 1), '/', 2206 str = cstrcat (str(1:s(i) - 1), '/',
2207 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', 2207 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}',
2208 str(e(i) + b2(1) + 1:end)); 2208 str(e(i) + b2(1) + 1:end));
2209 endif 2209 endif
2210 elseif(strcmpi (f, "fontsize")) 2210 elseif(strcmpi (f, "fontsize"))
2211 b1 = strfind(str(e(i) + 1:end),'{'); 2211 b1 = strfind(str(e(i) + 1:end),'{');
2212 b2 = strfind(str(e(i) + 1:end),'}'); 2212 b2 = strfind(str(e(i) + 1:end),'}');
2213 if (isempty(b1) || isempty(b2)) 2213 if (isempty(b1) || isempty(b2))
2214 warning ('syntax error in \fontname argument'); 2214 warning ('syntax error in \fontname argument');
2215 else 2215 else
2216 str = cstrcat (str(1:s(i) - 1), '/=', 2216 str = cstrcat (str(1:s(i) - 1), '/=',
2217 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', 2217 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}',
2218 str(e(i) + b2(1) + 1:end)); 2218 str(e(i) + b2(1) + 1:end));
2219 endif 2219 endif
2220 else 2220 else
2221 ## Last desperate attempt to treat the symbol. Look for things 2221 ## Last desperate attempt to treat the symbol. Look for things
2231 ## g = regexprep (g, '/Symbol', '/Symbol-bold'); 2231 ## g = regexprep (g, '/Symbol', '/Symbol-bold');
2232 ## endif 2232 ## endif
2233 ##elseif (it) 2233 ##elseif (it)
2234 ## g = regexprep (g, '/Symbol', '/Symbol-italic'); 2234 ## g = regexprep (g, '/Symbol', '/Symbol-italic');
2235 ##endif 2235 ##endif
2236 str = cstrcat (str(1:s(i) - 1), g, 2236 str = cstrcat (str(1:s(i) - 1), g,
2237 str(s(i) + length (flds{j}) + 1:end)); 2237 str(s(i) + length (flds{j}) + 1:end));
2238 break; 2238 break;
2239 endif 2239 endif
2240 endfor 2240 endfor
2241 endif 2241 endif