changeset 22348:9deb86bb5632

gl-render.cc: Draw minor grid lines at major ticks if major grid is off (bug #48528) * gl-render.cc (draw_axes_[xyz]_grid): Draw minor grid lines at major ticks if major grid is off. review and push by Andreas Weber <andy.weber.aw@gmail.com>
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 20 Aug 2016 15:24:42 +0200
parents 2b1612cf38e4
children 2aac9ec7df29
files libinterp/corefcn/gl-render.cc scripts/plot/appearance/grid.m
diffstat 2 files changed, 41 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/gl-render.cc	Sat Aug 20 14:46:18 2016 +0200
+++ b/libinterp/corefcn/gl-render.cc	Sat Aug 20 15:24:42 2016 +0200
@@ -1340,6 +1340,15 @@
         bool tick_along_z = nearhoriz || octave::math::isinf (fy);
         bool mirror = props.is_box () && xstate != AXE_ANY_DIR;
 
+        // set styles when drawing only minor grid
+        if (do_xminorgrid && ! do_xgrid)
+          {
+            gridstyle = minorgridstyle;
+            gridcolor = minorgridcolor;
+            gridalpha = minorgridalpha;
+            do_xgrid = true;
+          }
+
         set_color (props.get_xcolor_rgb ());
 
         // grid lines
@@ -1456,6 +1465,15 @@
         bool mirror = props.is_box () && ystate != AXE_ANY_DIR
           && (! props.has_property ("__plotyy_axes__"));
 
+        // set styles when drawing only minor grid
+        if (do_yminorgrid && ! do_ygrid)
+          {
+            gridstyle = minorgridstyle;
+            gridcolor = minorgridcolor;
+            gridalpha = minorgridalpha;
+            do_ygrid = true;
+          }
+
         set_color (props.get_ycolor_rgb ());
 
         // grid lines
@@ -1560,6 +1578,15 @@
         int hmax = 0;
         bool mirror = props.is_box () && zstate != AXE_ANY_DIR;
 
+        // set styles when drawing only minor grid
+        if (do_zminorgrid && ! do_zgrid)
+          {
+            gridstyle = minorgridstyle;
+            gridcolor = minorgridcolor;
+            gridalpha = minorgridalpha;
+            do_zgrid = true;
+          }
+
         set_color (props.get_zcolor_rgb ());
 
         // grid lines
--- a/scripts/plot/appearance/grid.m	Sat Aug 20 14:46:18 2016 +0200
+++ b/scripts/plot/appearance/grid.m	Sat Aug 20 15:24:42 2016 +0200
@@ -122,25 +122,32 @@
 
 endfunction
 
-
 %!demo
 %! clf;
-%! subplot (2,2,1);
+%! subplot (2, 3, 1);
 %!  plot (1:100);
 %!  grid off;
 %!  title ("no grid");
-%! subplot (2,2,2);
+%! subplot (2, 3, 2);
 %!  plot (1:100);
 %!  grid on;
 %!  title ("grid on");
-%! subplot (2,2,3);
+%! subplot (2, 3, 3);
 %!  plot (1:100);
-%!  grid off;
-%!  title ("no grid");
-%! subplot (2,2,4);
+%!  set (gca, "xgrid", "on")
+%!  title ("xgrid on");
+%! subplot (2, 3, 4);
+%!  plot (1:100);
+%!  set (gca, "ygrid", "on")
+%!  title ("ygrid on");
+%! subplot (2, 3, 5);
 %!  plot (1:100);
 %!  grid minor;
 %!  title ("grid minor");
+%! subplot (2, 3, 6);
+%!  plot (1:100);
+%!  set (gca, "yminorgrid", "on")
+%!  title ("yminorgrid on");
 
 %!demo
 %! subplot (2,2,1);
@@ -159,4 +166,3 @@
 %!  semilogy (1:100);
 %!  grid minor;
 %!  title ("grid minor");
-