changeset 22531:bcd2630c14f3

Remove persistent line style from gnuplot toolkit (bug #47974). * __gnuplot_has_feature__.m: Remove "linetype" and associated feature version. * __gnuplot_draw_axes__.m: Remove all conditional tests on gnuplot feature "linetype" and use appropriate "linestyle" or "style line" syntax. Condition the surface line drawing on plotting either lines (draw_surf_line) or markers (draw_surf_marker). Check for flat_marker, similar to flat_interp_edge. Broaden scope of style loop to include data generation and style option configurations. Define has_ccol for each style loop pass and if color column required expand data width from 3 to 4. Always use style option "ls #". Use 'has_ccol' in place of 'flat_interp_edge'. (do_linestyle_command): If flat_interp_edge, use 'palatte' in line style definition. Remove non-numeric markerfacecolor and markeredgecolor tests from conditional linecolor tests. If these two are not numeric values then print 'palette' for line style.
author Daniel J Sebald <daniel.sebald@ieee.org>
date Thu, 22 Sep 2016 14:39:10 -0500
parents db762b9b9b72
children c06e83d47ac3
files scripts/plot/util/private/__gnuplot_draw_axes__.m scripts/plot/util/private/__gnuplot_has_feature__.m
diffstat 2 files changed, 69 insertions(+), 83 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/private/__gnuplot_draw_axes__.m	Fri Sep 23 15:06:39 2016 +0200
+++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m	Thu Sep 22 14:39:10 2016 -0500
@@ -675,18 +675,13 @@
 
         [style, sidx] = do_linestyle_command (obj, obj.color, data_idx,
                                               plot_stream, errbars);
-        if (__gnuplot_has_feature__ ("linetype"))
-          scmd = "linetype";
-        else
-          scmd = "linestyle";
-        endif
 
         if isempty (style{1})
           style{1} = "points";
           data{data_idx} = {};
         endif
-        withclause{data_idx} = sprintf ("with %s %s %d",
-                                        style{1}, scmd, sidx(1));
+        withclause{data_idx} = sprintf ("with %s linestyle %d",
+                                        style{1}, sidx(1));
 
         if (length (style) > 1)
           data_idx += 1;
@@ -697,8 +692,8 @@
           titlespec{data_idx} = "title \"\"";
           usingclause{data_idx} = usingclause{data_idx - 1};
           data{data_idx} = data{data_idx - 1};
-          withclause{data_idx} = sprintf ("with %s %s %d",
-                                          style{2}, scmd, sidx(2));
+          withclause{data_idx} = sprintf ("with %s linestyle %d",
+                                          style{2}, sidx(2));
         endif
         if (length (style) > 2)
           data_idx += 1;
@@ -709,8 +704,8 @@
           titlespec{data_idx} = "title \"\"";
           usingclause{data_idx} = usingclause{data_idx - 1};
           data{data_idx} = data{data_idx - 1};
-          withclause{data_idx} = sprintf ("with %s %s %d",
-                                          style{3}, scmd, sidx(3));
+          withclause{data_idx} = sprintf ("with %s linestyle %d",
+                                          style{3}, sidx(3));
         endif
 
       case "patch"
@@ -1306,23 +1301,15 @@
                    interp_str, dord);
         endif
 
-        if (! strcmp (obj.linestyle, "none") && ! strcmp (obj.edgecolor, "none"))
+        draw_surf_line = ! strcmp (obj.linestyle, "none") && ! strcmp (obj.edgecolor, "none");
+        draw_surf_marker = (! strcmp (obj.marker, "none")
+                             && ! (strcmp (obj.markeredgecolor, "none")
+                                   && strcmp (obj.markerfacecolor, "none")));
+        if (draw_surf_line || draw_surf_marker)
           flat_interp_edge = (strcmp (obj.edgecolor, "flat")
                               || strcmp (obj.edgecolor, "interp"));
-          if (flat_interp_edge)
-            scmd = "palette";
-            ccol = ":($4)";
-            N_tup = 4;
-          else
-            if (__gnuplot_has_feature__ ("linetype"))
-              scmd = "linetype";
-            else
-              scmd = "linestyle";
-            endif
-            ccol = "";
-            N_tup = 3;
-          endif
-
+          flat_marker = (strcmp (obj.markeredgecolor, "flat") || strcmp (obj.markerfacecolor, "flat")
+                         || strcmp (obj.markeredgecolor, "auto") || strcmp (obj.markerfacecolor, "auto"));
           [style, sidx] = do_linestyle_command (obj, obj.edgecolor,
                                                 data_idx,
                                                 plot_stream);
@@ -1341,40 +1328,46 @@
           endif
 
           for np = 1:num_pass
-            if (np <= num_cols)
-              k = np;
-              yrec = ylen;
-              zz = zeros (ylen, N_tup);
-              zz(:,1) = xdat(:,k);
-              zz(:,2) = ydat(:,k);
-              zz(:,3) = zdat(:,k);
-              if (flat_interp_edge)
-                zz(:,4) = cdat(:,k);
+            for i_stl = 1:length (style)
+              has_ccol = ((strncmp (style{i_stl}, "lines", 5) && flat_interp_edge) ||
+                          (strncmp (style{i_stl}, "points", 6) && flat_marker));
+              if (has_ccol)
+                ccol = ":($4)";
+                N_tup = 4;
+              else
+                ccol = "";
+                N_tup = 3;
               endif
-            else
-              j = np - num_cols;
-              yrec = xlen;
-              zz = zeros (xlen, N_tup);
-              zz(:,1) = xdat(j,:)';
-              zz(:,2) = ydat(j,:)';
-              zz(:,3) = zdat(j,:)';
-              if (flat_interp_edge)
-                zz(:,4) = cdat(j,:)';
+              sopt = sprintf ("ls %d", sidx (i_stl));
+
+              if (np <= num_cols)
+                k = np;
+                yrec = ylen;
+                zz = zeros (ylen, N_tup);
+                zz(:,1) = xdat(:,k);
+                zz(:,2) = ydat(:,k);
+                zz(:,3) = zdat(:,k);
+                if (has_ccol)
+                  zz(:,4) = cdat(:,k);
+                endif
+              else
+                j = np - num_cols;
+                yrec = xlen;
+                zz = zeros (xlen, N_tup);
+                zz(:,1) = xdat(j,:)';
+                zz(:,2) = ydat(j,:)';
+                zz(:,3) = zdat(j,:)';
+                if (has_ccol)
+                  zz(:,4) = cdat(j,:)';
+                endif
               endif
-            endif
-
-            zz = zz.';
 
-            for i_stl = 1:length (style)
-              if (flat_interp_edge)
-                sopt = "";
-              else
-                sopt = sprintf ("%d", sidx(i_stl));
-              endif
+              zz = zz.';
+
               data_idx += 1;
               is_image_data(data_idx) = false;
               parametric(data_idx) = false;
-              if (flat_interp_edge)
+              if (has_ccol)
                 have_cdata(data_idx) = true;
               else
                 have_cdata(data_idx) = false;
@@ -1389,8 +1382,8 @@
               else
                 data{data_idx} = zz;
               endif
-              withclause{data_idx} = sprintf ("with %s %s %s",
-                                              style{i_stl}, scmd, sopt);
+              withclause{data_idx} = sprintf ("with %s %s",
+                                              style{i_stl}, sopt);
             endfor
           endfor
         endif
@@ -1559,13 +1552,8 @@
     else
       sidx_minor = 0;
     endif
-    if (__gnuplot_has_feature__ ("linetype"))
-      scmd = "linetype";
-    else
-      scmd = "linestyle";
-    endif
-    fprintf (plot_stream, "set grid %s %d, %s %d;\n",
-             scmd, sidx_major, scmd, sidx_minor);
+    fprintf (plot_stream, "set grid linestyle %d, linestyle %d;\n",
+             sidx_major, sidx_minor);
   endif
 
   if (! isempty (hlgnd) && ! isempty (hlgnd.children)
@@ -1916,13 +1904,8 @@
   style = {};
   ltidx = [];
 
-  if (__gnuplot_has_feature__ ("linetype"))
-    scommand = "linetype";
-  else
-    scommand = "style line";
-  endif
-  fprintf (plot_stream, "set %s %d default;\n", scommand, idx);
-  fprintf (plot_stream, "set %s %d", scommand, idx);
+  fprintf (plot_stream, "set style line %d default;\n", idx);
+  fprintf (plot_stream, "set style line %d", idx);
 
   found_style = false;
   if (isnumeric (linecolor))
@@ -1937,6 +1920,11 @@
              alphastr, round (255*color));
   else
     color = [0, 0, 0];
+    flat_interp_edge = (strcmp (obj.edgecolor, "flat")
+                        || strcmp (obj.edgecolor, "interp"));
+    if (flat_interp_edge)
+        fprintf (plot_stream, " palette");
+    endif
   endif
 
   lt = gnuplot_linestyletype (obj);
@@ -1971,7 +1959,6 @@
     if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor")
         && ! strcmp (obj.markerfacecolor, "none"))
       if (strcmp (obj.markerfacecolor, "auto")
-          || ! isnumeric (obj.markerfacecolor)
           || (isnumeric (obj.markerfacecolor)
               && isequal (color, obj.markerfacecolor)))
         if (! isempty (pt2))
@@ -1993,11 +1980,13 @@
         else
           fputs (plot_stream, ";\n");
         endif
-        fprintf (plot_stream, "set %s %d default;\n", scommand, idx);
-        fprintf (plot_stream, "set %s %d", scommand, idx);
+        fprintf (plot_stream, "set style line %d default;\n", idx);
+        fprintf (plot_stream, "set style line %d", idx);
         if (isnumeric (obj.markerfacecolor))
           fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
                    round (255*obj.markerfacecolor));
+        else
+          fprintf (plot_stream, " palette");
         endif
         if (! isempty (pt2))
           style{sidx} = "points";
@@ -2013,7 +2002,6 @@
         && ! strcmp (obj.markeredgecolor, "none"))
       if (facesame && ! isempty (pt)
           && (strcmp (obj.markeredgecolor, "auto")
-              || ! isnumeric (obj.markeredgecolor)
               || (isnumeric (obj.markeredgecolor)
                   && isequal (color, obj.markeredgecolor))))
         if (sidx == 1 && ((length (style{sidx}) == 5
@@ -2037,14 +2025,13 @@
         else
           fputs (plot_stream, ";\n");
         endif
-        fprintf (plot_stream, "set %s %d default;\n", scommand, idx);
-        fprintf (plot_stream, "set %s %d", scommand, idx);
-        if (strcmp (obj.markeredgecolor, "auto"))
-          fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
-                   round (255*color));
-        elseif (isnumeric (obj.markeredgecolor))
+        fprintf (plot_stream, "set style line %d default;\n", idx);
+        fprintf (plot_stream, "set style line %d", idx);
+        if (isnumeric (obj.markeredgecolor))
           fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
                    round (255*obj.markeredgecolor));
+        else
+          fprintf (plot_stream, " palette");
         endif
         if (! isempty (pt))
           style{sidx} = "points";
--- a/scripts/plot/util/private/__gnuplot_has_feature__.m	Fri Sep 23 15:06:39 2016 +0200
+++ b/scripts/plot/util/private/__gnuplot_has_feature__.m	Thu Sep 22 14:39:10 2016 -0500
@@ -27,7 +27,6 @@
 function res = __gnuplot_has_feature__ (feature)
   persistent features = {"minimum_version",
                          "needs_color_with_postscript",
-                         "linetype",
                          "dashtype",
                          "alphablend_linecolor",
                          "qt_terminal",
@@ -44,8 +43,8 @@
       ## Don't throw an error if gnuplot isn't installed
       gnuplot_version = "0.0.0";
     end_try_catch
-    versions  = {"4.4", "4.6", "4.6", "5.0", "4.6", "4.6", "5.0", "5.0", "5.0"};
-    operators = {">=" , ">=" , ">=" , ">=" , ">=" , ">=" , ">=" , ">=" , ">=" };
+    versions  = {"4.4", "4.6", "5.0", "4.6", "4.6", "5.0", "5.0", "5.0"};
+    operators = {">=" , ">=" , ">=" , ">=" , ">=" , ">=" , ">=" , ">=" };
     have_features = false (size (features));
     for n = 1 : numel (have_features)
       has_features(n) = compare_versions (gnuplot_version, versions{n}, operators{n});