changeset 22366:837df5db5710

Make graphic functions visually compatible w/Matlab. * image.m: Turn "box" on. * legend.m: Use '#' in BIST titles. * area.m: Turn "box" on. Fix transpose operator that was accidentally changed to `"'. * colorbar.m: Turn "box" on. Remove logscale colorbar BIST demo since it doesn't work for Octave or Matlab. * contour.m: Turn "box" on. * fill.m: Turn "box" on. * isosurface.m: Use cell array of strings in annotation box of %!demo to get multi-line strings. Remove newline. * light.m: Use cell array of strings in annotation box of %!demo to get multi-line strings. * loglog.m: Turn "box" on. * loglogerr.m: Turn "box" on. * __bar__.m: Turn "box" on. * __quiver__.m: Rename 'h' to 'hax' for clarity. * quiver.m: Turn "box" on. * semilogx.m: Turn "box" on. * semilogy.m: Turn "box" on. * shrinkfaces.m: Call 'axis auto' to update plot limits before calling 'axis equal'. This is a kludge that should be fixed in axis. * stairs.m: Turn "box" on.
author Rik <rik@octave.org>
date Tue, 23 Aug 2016 10:12:28 -0700
parents 119f408f2dd1
children 459545bc9019
files scripts/image/image.m scripts/plot/appearance/legend.m scripts/plot/draw/area.m scripts/plot/draw/colorbar.m scripts/plot/draw/contour.m scripts/plot/draw/fill.m scripts/plot/draw/isosurface.m scripts/plot/draw/light.m scripts/plot/draw/loglog.m scripts/plot/draw/loglogerr.m scripts/plot/draw/private/__bar__.m scripts/plot/draw/private/__quiver__.m scripts/plot/draw/quiver.m scripts/plot/draw/semilogx.m scripts/plot/draw/semilogy.m scripts/plot/draw/shrinkfaces.m scripts/plot/draw/stairs.m
diffstat 17 files changed, 55 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/image/image.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/image/image.m	Tue Aug 23 10:12:28 2016 -0700
@@ -194,7 +194,7 @@
 
     endif  # ! isempty (img)
 
-    set (hax, "view", [0, 90], "ydir", "reverse", "layer", "top");
+    set (hax, "view", [0, 90], "ydir", "reverse", "layer", "top", "box", "on");
 
   endif  # do_new
 
--- a/scripts/plot/appearance/legend.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/appearance/legend.m	Tue Aug 23 10:12:28 2016 -0700
@@ -1452,7 +1452,7 @@
 %! y1 = rand (size (x));
 %! y2 = rand (size (x));
 %! [ax, h1, h2] = plotyy (x, y1, x, y2);
-%! title ("plotyy legend test 1: Blue and Green labels");
+%! title ("plotyy legend test #1: Blue and Green labels");
 %! legend ([h1, h2], {"Blue", "Green"}, "location", "south");
 
 %!demo
@@ -1461,7 +1461,7 @@
 %! y1 = rand (size (x));
 %! y2 = rand (size (x));
 %! [ax, h1, h2] = plotyy (x, y1, x, y2);
-%! title ("plotyy legend test 2: Blue and Green labels");
+%! title ("plotyy legend test #2: Blue and Green labels");
 %! legend ({"Blue", "Green"}, "location", "south");
 
 %!demo
@@ -1470,7 +1470,7 @@
 %! y1 = rand (size (x));
 %! y2 = rand (size (x));
 %! [ax, h1, h2] = plotyy (x, y1, x, y2);
-%! title ("plotyy legend test 3: Blue and Green labels");
+%! title ("plotyy legend test #3: Blue and Green labels");
 %! legend ("Blue", "Green", "location", "south");
 
 %!demo
--- a/scripts/plot/draw/area.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/area.m	Tue Aug 23 10:12:28 2016 -0700
@@ -115,6 +115,11 @@
   unwind_protect
     hax = newplot (hax);
     htmp = __area__ (hax, x, y, bv, varargin{num_numeric+1:end});
+
+    if (! ishold (hax))
+      set (hax, "box", "on");
+    endif
+
   unwind_protect_cleanup
     if (! isempty (oldfig))
       set (0, "currentfigure", oldfig);
@@ -248,7 +253,7 @@
 %!demo
 %! ## Verify identity sin^2 + cos^2 = 1
 %! clf;
-%! t = linspace (0, 2*pi, 100)";
+%! t = linspace (0, 2*pi, 100)';
 %! y = [sin(t).^2, cos(t).^2];
 %! area (t, y);
 %! axis tight
@@ -258,7 +263,7 @@
 %!demo
 %! ## Show effects of setting BaseValue
 %! clf;
-%! x = [-2:0.1:2]";
+%! x = [-2:0.1:2]';
 %! y = x.^2 - 1;
 %! subplot (1, 2, 1)
 %!  area (x, y);
--- a/scripts/plot/draw/colorbar.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/colorbar.m	Tue Aug 23 10:12:28 2016 -0700
@@ -195,7 +195,8 @@
     cax = __go_axes__ (hpar, "tag", "colorbar",
                              "handlevisibility", "on",
                              "activepositionproperty", "position",
-                             "position", cpos);
+                             "position", cpos,
+                             "box", "on");
     addproperty ("location", cax, "radio",
                  "eastoutside|east|westoutside|west|northoutside|north|southoutside|south",
                  loc);
@@ -681,13 +682,6 @@
 %!demo
 %! clf;
 %! colormap ("default");
-%! imagesc (1 ./ hilb (99));
-%! h = colorbar ();
-%! set (h, "yscale", "log");
-
-%!demo
-%! clf;
-%! colormap ("default");
 %! imagesc (log10 (1 ./ hilb (99)));
 %! h = colorbar ();
 %! ytick = get (h, "ytick");
--- a/scripts/plot/draw/contour.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/contour.m	Tue Aug 23 10:12:28 2016 -0700
@@ -72,6 +72,11 @@
     hax = newplot (hax);
 
     [ctmp, htmp] = __contour__ (hax, "none", varargin{:});
+
+    if (! ishold (hax))
+      set (hax, "box", "on");
+    endif
+
   unwind_protect_cleanup
     if (! isempty (oldfig))
       set (0, "currentfigure", oldfig);
--- a/scripts/plot/draw/fill.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/fill.m	Tue Aug 23 10:12:28 2016 -0700
@@ -88,6 +88,9 @@
   unwind_protect
     hax = newplot (hax);
     old_nxtplt = get (hax, "nextplot");
+    if (! ishold ())
+      set (hax, "box", "on");
+    endif
     unwind_protect
       set (hax, "nextplot", "add");
 
--- a/scripts/plot/draw/isosurface.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/isosurface.m	Tue Aug 23 10:12:28 2016 -0700
@@ -415,10 +415,10 @@
 %!  shading faceted;
 %!  view (110, 40);
 %!  annotation ("textbox", [0.1 0.9 0.9 0.1], ...
-%!      "String", ["Apart from the first plot having a different scale, " ...
-%!      "all four plots must look the same.\n" ...
-%!      "The last plot might have different colors but must have " ...
-%!      "the same shape."], ...
+%!      "String", {["Apart from the first plot having a different scale, " ...
+%!                  "all four plots must look the same."],
+%!                 ["The last plot might have different colors but must " ...
+%!                  "have the same shape."]}, ...
 %!      "HorizontalAlignment", "left", ...
 %!      "FontSize", 12);
 
--- a/scripts/plot/draw/light.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/light.m	Tue Aug 23 10:12:28 2016 -0700
@@ -265,7 +265,7 @@
 %! axis equal
 %! view (2);
 %! xlabel ("AmbientStrength");
-%! ylabel ("AmbientLightColor [0 1 0]");
+%! ylabel ({"AmbientLightColor", "[0 1 0]"});
 %!
 %! h_axes2 = subplot (3,1,2);
 %! set (h_axes2, "AmbientLightColor", [.5 0 1]);
@@ -288,7 +288,7 @@
 %! axis tight
 %! axis equal
 %! view (2);
-%! ylabel ("AmbientLightColor [.5 0 1]");
+%! ylabel ({"AmbientLightColor", "[.5 0 1]"});
 %!
 %! h_axes3 = subplot (3,1,1);
 %! set (h_axes3, "AmbientLightColor", "w");
@@ -311,7 +311,7 @@
 %! axis tight
 %! axis equal
 %! view (2);
-%! ylabel ("AmbientLightColor [1 1 1]");
+%! ylabel ({"AmbientLightColor", "[1 1 1]"});
 %! title ("Effects of AmbientLightColor and AmbientStrength");
 
 %!demo
--- a/scripts/plot/draw/loglog.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/loglog.m	Tue Aug 23 10:12:28 2016 -0700
@@ -54,7 +54,7 @@
 
     set (hax, "xscale", "log", "yscale", "log");
     if (! ishold (hax))
-      set (hax, "xminortick", "on", "yminortick", "on");
+      set (hax, "xminortick", "on", "yminortick", "on", "box", "on");
     endif
 
     htmp = __plt__ ("loglog", hax, varargin{:});
--- a/scripts/plot/draw/loglogerr.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/loglogerr.m	Tue Aug 23 10:12:28 2016 -0700
@@ -64,7 +64,7 @@
 
     set (hax, "xscale", "log", "yscale", "log");
     if (! ishold (hax))
-      set (hax, "xminortick", "on", "yminortick", "on");
+      set (hax, "xminortick", "on", "yminortick", "on", "box", "on");
     endif
     htmp = __errplot__ ("loglogerr", hax, varargin{:});
 
--- a/scripts/plot/draw/private/__bar__.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/private/__bar__.m	Tue Aug 23 10:12:28 2016 -0700
@@ -209,6 +209,7 @@
         else
           set (hax, "clim", [0 1], "ylimmode", "manual");
         endif
+        set (hax, "box", "on");
       endif
     unwind_protect_cleanup
       if (! isempty (oldfig))
--- a/scripts/plot/draw/private/__quiver__.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/private/__quiver__.m	Tue Aug 23 10:12:28 2016 -0700
@@ -23,7 +23,7 @@
 
 function hg = __quiver__ (varargin)
 
-  h = varargin{1};
+  hax = varargin{1};
   is3d = varargin{2};
 
   autoscale = 0.9;
@@ -147,7 +147,7 @@
     endif
   endif
 
-  hstate = get (h, "nextplot");
+  hstate = get (hax, "nextplot");
   unwind_protect
 
     if (have_line_spec)
@@ -167,7 +167,8 @@
       args = __add_datasource__ ("quiver", hg,
                                  {"x", "y", "z", "u", "v", "w"}, args{:});
     endif
-    hold on;
+
+    hold (hax, "on");
 
     addproperty ("xdata", hg, "data", x);
     addproperty ("ydata", hg, "data", y);
@@ -301,7 +302,7 @@
       set (hg, args{:});
     endif
   unwind_protect_cleanup
-    set (h, "nextplot", hstate);
+    set (hax, "nextplot", hstate);
   end_unwind_protect
 
 endfunction
--- a/scripts/plot/draw/quiver.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/quiver.m	Tue Aug 23 10:12:28 2016 -0700
@@ -80,6 +80,13 @@
   unwind_protect
     hax = newplot (hax);
     htmp = __quiver__ (hax, false, varargin{:});
+
+    ## FIXME: This should be moved into __quiver__ when problem with
+    ##        re-initialization of title object is fixed.
+    if (! ishold ())
+      set (hax, "box", "on");
+    endif
+
   unwind_protect_cleanup
     if (! isempty (oldfig))
       set (0, "currentfigure", oldfig);
--- a/scripts/plot/draw/semilogx.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/semilogx.m	Tue Aug 23 10:12:28 2016 -0700
@@ -54,7 +54,7 @@
 
     set (hax, "xscale", "log");
     if (! ishold (hax))
-      set (hax, "xminortick", "on");
+      set (hax, "xminortick", "on", "box", "on");
     endif
 
     htmp = __plt__ ("semilogx", hax, varargin{:});
--- a/scripts/plot/draw/semilogy.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/semilogy.m	Tue Aug 23 10:12:28 2016 -0700
@@ -54,7 +54,7 @@
 
     set (hax, "yscale", "log");
     if (! ishold (hax))
-      set (hax, "yminortick", "on");
+      set (hax, "yminortick", "on", "box", "on");
     endif
 
     htmp = __plt__ ("semilogy", hax, varargin{:});
--- a/scripts/plot/draw/shrinkfaces.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/shrinkfaces.m	Tue Aug 23 10:12:28 2016 -0700
@@ -158,6 +158,7 @@
 %! patch ("Faces", faces, "Vertices", vertices, "FaceColor", "none");
 %! fv = shrinkfaces (faces, vertices, 0.25);
 %! patch (fv);
+%! axis auto;   # Kludge required for Octave
 %! axis equal;
 
 %!demo
@@ -167,6 +168,7 @@
 %! patch ("Faces", faces, "Vertices", vertices, "FaceColor", "none");
 %! fv = shrinkfaces (faces, vertices, 0.25);
 %! patch (fv);
+%! axis auto;   # Kludge required for Octave
 %! axis equal;
 %! grid on;
 
@@ -177,6 +179,7 @@
 %! patch ("Faces", faces, "Vertices", vertices, "FaceColor", "none");
 %! fv = shrinkfaces (faces, vertices, 0.25);
 %! patch (fv);
+%! axis auto;   # Kludge required for Octave
 %! axis equal;
 %! grid on;
 %! title "faces which are not convex are clearly not allowed"
@@ -189,6 +192,7 @@
 %! p = patch ("Faces", tri, "Vertices", v, "FaceColor", "none");
 %! fv = shrinkfaces (p);
 %! patch (fv);
+%! axis auto;   # Kludge required for Octave
 %! axis equal;
 %! grid on;
 
@@ -201,6 +205,7 @@
 %!
 %! p = patch ("Faces", fv.faces, "Vertices", fv.vertices, "FaceVertexCData", ...
 %!            fv.facevertexcdata, "FaceColor", "interp", "EdgeColor", "black");
+%! axis auto;   # Kludge required for Octave
 %! axis equal;
 %! view (115, 30);
 %! drawnow;
--- a/scripts/plot/draw/stairs.m	Tue Aug 23 15:37:21 2016 +0100
+++ b/scripts/plot/draw/stairs.m	Tue Aug 23 10:12:28 2016 -0700
@@ -80,6 +80,11 @@
     unwind_protect
       hax = newplot (hax);
       [htmp, xxs, yys] = __stairs__ (true, varargin{:});
+
+      if (! ishold ())
+        set (hax, "box", "on");
+      endif
+
     unwind_protect_cleanup
       if (! isempty (oldfig))
         set (0, "currentfigure", oldfig);