exporting patch:
# HG changeset patch
# User Daniel J Sebald <daniel.sebald@ieee.org>
# Date 1464273270 18000
#      Thu May 26 09:34:30 2016 -0500
# Node ID 4dd0fe91f88f5bc393f8810ce9135772056c95ad
# Parent  d6826b38b29ced0b059dd1137990cd4bdcb96631
Implement graphics property meshstyle for gnuplot graphics toolkit (bug #47974)

* waterfall.m: Remove comment about gnuplot graphics toolkit deficiency.

* __gnuplot_draw_axes__.m: For surface case, if obj.meshstyle is not 'both',
  do multiple passes whereby individual surface lines are drawn by creating
  pairs of repeated data.

diff --git a/scripts/plot/draw/waterfall.m b/scripts/plot/draw/waterfall.m
--- a/scripts/plot/draw/waterfall.m
+++ b/scripts/plot/draw/waterfall.m
@@ -64,12 +64,6 @@ function h = waterfall (varargin)
 
   set (htmp, "meshstyle", "row");
 
-  ## The gnuplot toolkit does nothing with the meshstyle property currently.
-  toolkit = get (ancestor (htmp, "figure"), "__graphics_toolkit__");
-  if (strcmp (toolkit, "gnuplot"))
-    warning ("waterfall: may not render correctly using toolkit '%s'", toolkit);
-  endif
-
   if (nargout > 0)
     h = htmp;
   endif
diff --git a/scripts/plot/util/private/__gnuplot_draw_axes__.m b/scripts/plot/util/private/__gnuplot_draw_axes__.m
--- a/scripts/plot/util/private/__gnuplot_draw_axes__.m
+++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m
@@ -1226,41 +1226,78 @@ function __gnuplot_draw_axes__ (h, plot_
           else
             N_tup = 3;
           endif
-          len = N_tup * xlen;
-          zz = zeros (ylen, len);
-          k = 1;
-          for kk = 1:N_tup:len
-            zz(:,kk)   = xdat(:,k);
-            zz(:,kk+1) = ydat(:,k);
-            zz(:,kk+2) = zdat(:,k);
-            if (flat_interp_edge)
-              zz(:,kk+3) = cdat(:,k);
+          meshboth = strcmp (obj.meshstyle, "both");
+          if (meshboth)
+            meshcolumn = true;
+            len = N_tup * xlen;
+            xlen_pass = xlen;
+            num_pass = 1;
+          else
+            meshcolumn = strcmp (obj.meshstyle, "column");
+            len = N_tup * 2;
+            xlen_pass = 2;
+            if (meshcolumn)
+              num_pass = xlen;
+            else
+              num_pass = ylen;
             endif
-            k += 1;
-          endfor
+          endif
 
-          zz = zz.';
+          for np = 1:num_pass
+            if (meshcolumn)
+              k = np;
+              zz = zeros (ylen, len);
+              for kk = 1:N_tup:len
+                zz(:,kk)   = xdat(:,k);
+                zz(:,kk+1) = ydat(:,k);
+                zz(:,kk+2) = zdat(:,k);
+                if (flat_interp_edge)
+                  zz(:,kk+3) = cdat(:,k);
+                endif
+                if (meshboth)
+                  k += 1;
+                endif
+              endfor
+            else
+              j = np;
+              zz = zeros (xlen, len);
+              for kk = 1:N_tup:len
+                zz(:,kk)   = xdat(j,:)';
+                zz(:,kk+1) = ydat(j,:)';
+                zz(:,kk+2) = zdat(j,:)';
+                if (flat_interp_edge)
+                  zz(:,kk+3) = cdat(j,:)';
+                endif
+                if (meshboth)
+                  k += 1;
+                endif
+              endfor
+            endif
 
-          for i_stl = 1:length (style)
-            if (flat_interp_edge)
-              sopt = "";
-            else
-              sopt = sprintf("%d", sidx(i_stl));
-            endif
-            data_idx += 1;
-            is_image_data(data_idx) = false;
-            parametric(data_idx) = false;
-            if (flat_interp_edge)
-              have_cdata(data_idx) = true;
-            else
-              have_cdata(data_idx) = false;
-            end
-            have_3d_patch(data_idx) = false;
-            titlespec{data_idx} = tspec;
-            usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)%s", ylen, xlen, ccol);
-            data{data_idx} = zz;
-            withclause{data_idx} = sprintf ("with %s %s %s",
-                                             style{i_stl}, scmd, sopt);
+            zz = zz.';
+
+            for i_stl = 1:length (style)
+              if (flat_interp_edge)
+                sopt = "";
+              else
+                sopt = sprintf("%d", sidx(i_stl));
+              endif
+              data_idx += 1;
+              is_image_data(data_idx) = false;
+              parametric(data_idx) = false;
+              if (flat_interp_edge)
+                have_cdata(data_idx) = true;
+              else
+                have_cdata(data_idx) = false;
+              end
+              have_3d_patch(data_idx) = false;
+              titlespec{data_idx} = tspec;
+              usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)%s", ylen, xlen_pass, ccol);
+              data{data_idx} = zz;
+              withclause{data_idx} = sprintf ("with %s %s %s",
+                                               style{i_stl}, scmd, sopt);
+            endfor
+
           endfor
 
         endif
