Mercurial > hg > octave-nkf
comparison scripts/plot/__go_draw_axes__.m @ 8166:4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Tue, 30 Sep 2008 16:09:09 -0400 |
parents | 0d37c99fc06f |
children | 15ffb9836c01 |
comparison
equal
deleted
inserted
replaced
8165:75014ec4ac84 | 8166:4024fc815f8d |
---|---|
21 ## Author: jwe | 21 ## Author: jwe |
22 | 22 |
23 function __go_draw_axes__ (h, plot_stream, enhanced, mono) | 23 function __go_draw_axes__ (h, plot_stream, enhanced, mono) |
24 | 24 |
25 if (nargin == 4) | 25 if (nargin == 4) |
26 | |
27 ## Gnupot versions > 4.2.4 include a patch to properly interpolate | |
28 ## colors. Prior to that version the interpolation of colors used | |
29 ## the zdata rather than the cdata. | |
30 ## | |
31 ## FIXME: when gnuplot 4.3 is released the special treatment might | |
32 ## be removed. | |
33 | |
34 persistent gp_version_gt_4p2p4 = ... | |
35 compare_versions (__gnuplot_version__ (), "4.2.4", ">"); | |
26 | 36 |
27 axis_obj = __get__ (h); | 37 axis_obj = __get__ (h); |
28 | 38 |
29 parent_figure_obj = get (axis_obj.parent); | 39 parent_figure_obj = get (axis_obj.parent); |
30 | 40 |
311 obj = get (kids(1)); | 321 obj = get (kids(1)); |
312 kids = kids(2:end); | 322 kids = kids(2:end); |
313 | 323 |
314 if (strcmp (obj.visible, "off")) | 324 if (strcmp (obj.visible, "off")) |
315 continue; | 325 continue; |
326 endif | |
327 | |
328 ## Check for color interpolation for surfaces. | |
329 doing_interp_color = strncmp (obj.facecolor, "interp", 6); | |
330 if (doing_interp_color) | |
331 ## Check to see if gnuplot is fully functional in this regard. | |
332 if (gp_version_gt_4p2p4) | |
333 ## Color interpolation works correctly in gnuplot >4.2.4. | |
334 fake_color_interp = false; | |
335 else | |
336 ## The patches may be applied to >4.2.2, but don't count on it. | |
337 ## For versions >4.1 & <4.2.5 the interpolation uses the zdata | |
338 ## rather than the cdata. As a result surfc() will work because | |
339 ## all(zdata(:)==cdata(:)). pcolor() may be given the illusion | |
340 ## of working when the veiw is directly from above. | |
341 fake_color_interp = (all (axis_obj.view == [0, 90]) | |
342 || all (obj.zdata(:) == obj.cdata(:))); | |
343 endif | |
344 else | |
345 fake_color_interp = false; | |
316 endif | 346 endif |
317 | 347 |
318 switch (obj.type) | 348 switch (obj.type) |
319 case "image" | 349 case "image" |
320 img_data = obj.cdata; | 350 img_data = obj.cdata; |
813 zz(:,kk+3) = cdat(:,k); | 843 zz(:,kk+3) = cdat(:,k); |
814 k++; | 844 k++; |
815 endfor | 845 endfor |
816 data{data_idx} = zz.'; | 846 data{data_idx} = zz.'; |
817 endif | 847 endif |
818 usingclause{data_idx} = "using ($1):($2):($3):($4)"; | 848 |
819 ## fputs (plot_stream, "unset parametric;\n"); | 849 if (doing_interp_color) |
820 | 850 interp_str = "interpolate 4, 4"; |
821 ## Interpolation does not work for flat surfaces (e.g. pcolor) | 851 if (fake_color_interp) |
822 ## and color mapping --> currently set empty. | 852 ## In this instance the interpolation of color respects zdata |
823 interp_str = ""; | 853 ## rather than cdata. |
854 usingclause{data_idx} = "using ($1):($2):($4)"; | |
855 else | |
856 ## The proper gnuplot inputs include xdata, ydata, zdata, & cdata. | |
857 usingclause{data_idx} = "using ($1):($2):($3):($4)"; | |
858 endif | |
859 else | |
860 ## No interpolation of colors. | |
861 interp_str = ""; | |
862 usingclause{data_idx} = "using ($1):($2):($3):($4)"; | |
863 endif | |
864 | |
824 flat_interp_face = (strncmp (obj.facecolor, "flat", 4) | 865 flat_interp_face = (strncmp (obj.facecolor, "flat", 4) |
825 || strncmp (obj.facecolor, "interp", 6)); | 866 || strncmp (obj.facecolor, "interp", 6)); |
826 flat_interp_edge = (strncmp (obj.edgecolor, "flat", 4) | 867 flat_interp_edge = (strncmp (obj.edgecolor, "flat", 4) |
827 || strncmp (obj.edgecolor, "interp", 6)); | 868 || strncmp (obj.edgecolor, "interp", 6)); |
828 | 869 |
855 fputs(plot_stream,"set style increment user;\n"); | 896 fputs(plot_stream,"set style increment user;\n"); |
856 withclause{data_idx} = sprintf("with line linestyle %d", data_idx); | 897 withclause{data_idx} = sprintf("with line linestyle %d", data_idx); |
857 fputs (plot_stream, "unset pm3d\n"); | 898 fputs (plot_stream, "unset pm3d\n"); |
858 endif | 899 endif |
859 | 900 |
860 dord = "depthorder"; | 901 if (doing_interp_color) |
902 ## "depthorder" interferes with interpolation of colors. | |
903 dord = "scansautomatic"; | |
904 else | |
905 dord = "depthorder"; | |
906 endif | |
861 | 907 |
862 if (flat_interp_face && strncmp (obj.edgecolor, "flat", 4)) | 908 if (flat_interp_face && strncmp (obj.edgecolor, "flat", 4)) |
863 fprintf (plot_stream, "set pm3d explicit at s %s %s corners2color c3;\n", | 909 fprintf (plot_stream, "set pm3d explicit at s %s %s corners2color c3;\n", |
864 interp_str, dord); | 910 interp_str, dord); |
865 elseif (!facecolor_none_or_white) | 911 elseif (!facecolor_none_or_white) |
979 if (strcmpi (axis_obj.zdir, "reverse")) | 1025 if (strcmpi (axis_obj.zdir, "reverse")) |
980 zdir = "reverse"; | 1026 zdir = "reverse"; |
981 else | 1027 else |
982 zdir = "noreverse"; | 1028 zdir = "noreverse"; |
983 endif | 1029 endif |
984 fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir); | 1030 if (doing_interp_color) |
1031 if (! fake_color_interp || any (obj.zdata(:) ~= 0)) | |
1032 fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir); | |
1033 end | |
1034 else | |
1035 fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir); | |
1036 endif | |
985 endif | 1037 endif |
986 | 1038 |
987 cmap = parent_figure_obj.colormap; | 1039 cmap = parent_figure_obj.colormap; |
988 cmap_sz = rows(cmap); | 1040 cmap_sz = rows(cmap); |
989 | 1041 |