exporting patch:
# HG changeset patch
# User Daniel J Sebald <daniel.sebald@ieee.org>
# Date 1507144429 18000
#      Wed Oct 04 14:13:49 2017 -0500
# Node ID 582215ee04a62f505e1549b6206982d8ec0705f6
# Parent  01df6b5209f489780e007c012d21b3a1b7d47005
Handle x-axis and y-axis independently for proper axis lines and tick marks (bug #52141)

* __gnuplot_draw_axes__.m: Move do_border_2d() sooner and un-conditioned on
  no (empty) y-ticks, thereby addressing missing axis lines.  Condense
  duplicate x-tick processing code into a separate group of if-else tests even
  in the empty y-tick scenario, thereby addressing extra mirrored x-ticks.

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
@@ -1486,43 +1486,20 @@ function __gnuplot_draw_axes__ (h, plot_
     else
       if (nd == 3)
         do_border_tick_3d (axis_obj, plot_stream);
-      elseif (! isempty (axis_obj.ytick))
-        if (strcmp (axis_obj.yaxislocation, "right"))
-          fprintf (plot_stream, "unset ytics; set y2tics %s nomirror\n",
-                   axis_obj.tickdir);
-          if (strcmp (axis_obj.xaxislocation, "top"))
-            maybe_do_x2tick_mirror (plot_stream, axis_obj)
-          elseif (strcmp (axis_obj.xaxislocation, "bottom"))
-            maybe_do_xtick_mirror (plot_stream, axis_obj)
-          else # xaxislocation == "origin" or "zero"
-            fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n",
-                     axis_obj.tickdir);
-          endif
-        elseif (strcmp (axis_obj.yaxislocation, "left"))
-          fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
-                   axis_obj.tickdir);
-          if (strcmp (axis_obj.xaxislocation, "top"))
-            maybe_do_x2tick_mirror (plot_stream, axis_obj)
-          elseif (strcmp (axis_obj.xaxislocation, "bottom"))
-            maybe_do_xtick_mirror (plot_stream, axis_obj)
-          else # xaxislocation == "origin" or "zero"
-            maybe_do_xtick_mirror (plot_stream, axis_obj)
-          endif
-        else # yaxislocation == "origin" or "zero"
-          fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
-                   axis_obj.tickdir);
-          if (strcmp (axis_obj.xaxislocation, "top"))
-            maybe_do_x2tick_mirror (plot_stream, axis_obj)
-          elseif (strcmp (axis_obj.xaxislocation, "bottom"))
-            maybe_do_xtick_mirror (plot_stream, axis_obj)
-          else # xaxislocation == "origin" or "zero"
-            maybe_do_xtick_mirror (plot_stream, axis_obj)
-            fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
-                     axis_obj.tickdir);
-            fputs (plot_stream, "unset border;\n");
-          endif
+      else
+        axis_idx = do_border_2d (axis_obj, plot_stream, axis_idx);
+        if (isempty (axis_obj.xtick))
+        elseif (strcmp (axis_obj.xaxislocation, "top"))
+          fprintf (plot_stream, "set x2tics %s nomirror\n", axis_obj.tickdir);
+        else # xaxislocation == "bottom", "origin" or "zero"
+          fprintf (plot_stream, "set xtics %s nomirror\n", axis_obj.tickdir);
         endif
-        axis_idx = do_border_2d (axis_obj, plot_stream, axis_idx);
+        if (isempty (axis_obj.ytick))
+        elseif (strcmp (axis_obj.yaxislocation, "right"))
+          fprintf (plot_stream, "set y2tics %s nomirror\n", axis_obj.tickdir);
+        else # yaxislocation == "left", "origin" or "zero"
+          fprintf (plot_stream, "set ytics %s nomirror\n",  axis_obj.tickdir);
+        endif
       endif
     endif
   endif
@@ -2876,24 +2853,6 @@ function do_text (stream, gpterm, enhanc
 
 endfunction
 
-function maybe_do_xtick_mirror (plot_stream, axis_obj)
-
-  if (! isempty(axis_obj.xtick))
-    fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n",
-                          axis_obj.tickdir);
-  endif
-
-endfunction
-
-function maybe_do_x2tick_mirror (plot_stream, axis_obj)
-
-  if (! isempty(axis_obj.xtick))
-    fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n",
-                          axis_obj.tickdir);
-  endif
-
-endfunction
-
 function retval = mapcdata (cdata, mode, clim, cmap_sz)
   if (ndims (cdata) == 3)
     ## True Color, clamp data to 8-bit
