exporting patch:
# HG changeset patch
# User Daniel J Sebald <daniel.sebald@ieee.org>
# Date 1464448111 18000
#      Sat May 28 10:08:31 2016 -0500
# Node ID 763dff5d935308a1b06ef20caebe0304046c4843
# 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 and edges, use multiple passes to
  describe mesh as individual gnuplot lines rather than gnuplot surface.  If
  obj.meshstyle is 'both', do both column and row directions.

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,72 @@ 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);
+          domeshcolumn = (strcmp (obj.meshstyle, "column") || strcmp (obj.meshstyle, "both"));
+          domeshrow = (strcmp (obj.meshstyle, "row") || strcmp (obj.meshstyle, "both"));
+          num_pass = 0;
+          num_cols = 0;
+          len = N_tup * 1;
+          if (domeshcolumn)
+            num_pass = num_pass + xlen;
+            num_cols = xlen;
+          endif
+          if (domeshrow)
+            num_pass = num_pass + ylen;
+          endif
+
+          for np = 1:num_pass
+            if (np <= num_cols)
+              k = np;
+              xrec = len / N_tup;
+              yrec = ylen;
+              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
+              endfor
+            else
+              j = np - num_cols;
+              xrec = len / N_tup;
+              yrec = xlen;
+              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
+              endfor
             endif
-            k += 1;
-          endfor
 
-          zz = zz.';
+            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, ccol);
-            data{data_idx} = zz;
-            withclause{data_idx} = sprintf ("with %s %s %s",
-                                             style{i_stl}, scmd, sopt);
+            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", yrec, xrec, ccol);
+              data{data_idx} = zz;
+              withclause{data_idx} = sprintf ("with %s %s %s",
+                                               style{i_stl}, scmd, sopt);
+            endfor
+
           endfor
 
         endif
