diff scripts/plot/util/ishold.m @ 22069:9121d6584f6a

Overhaul graphics implementation of hold() (bug #43559). * NEWS: Announce possible color changes in plots relying on "hold on". * hold.m: Deprecate "hold all" in docstring. Eliminate use of __hold_all__ graphics property. Update %!demo to use "hold on" only. * ishold.m: Put input validation first. Use switch statement rather than if/else tree for clarity. * graphics.in.h: Remove hidden __hold_all__ graphics property of axes. * graphics.cc (axes::properties::set_defaults): Remove use of __hold_all__. * newplot.m: Delete kluge use of __next_line_color__ and __next_line_style__. Set colororderindex and linestyleorderindex to 1 on new plots. * __next_line_color__.m: Completely rewrite to use the axes graphic property "colororderindex" to keep track of which color should be used next. Also increment "linestyleorderindex" when number of colors used rolls over so that colors will repeat with the next linestyle in the series. Update BIST test. * __next_line_style__.m: Completely rewrite to use the axes graphic property "linestyleorderindex" to keep track of which linestyle should be used next. * imagesc.m, axis.m, legend.m: Replace "hold all" with "hold on" in all demos.
author Rik <rik@octave.org>
date Thu, 07 Jul 2016 13:07:03 -0700
parents 516bb87ea72e
children bac0d6f07a3e
line wrap: on
line diff
--- a/scripts/plot/util/ishold.m	Thu Jul 07 12:15:46 2016 -0700
+++ b/scripts/plot/util/ishold.m	Thu Jul 07 13:07:03 2016 -0700
@@ -38,19 +38,23 @@
     fig = gcf ();
     ax = get (fig, "currentaxes");
   else
-    if (ishandle (h))
-      if (strcmp (get (h, "type"), "figure"))
+    if (! ishandle (h))
+      error ("ishold: H must be an axes or figure graphics handle");
+    endif
+
+    switch (get (h, "type"))
+      case "figure"
         fig = h;
         ax = get (fig, "currentaxes");
-      elseif (strcmp (get (h, "type"), "axes"))
+
+      case "axes"
         ax = h;
         fig = ancestor (ax, "figure");
-      else
+
+      otherwise
         error ("ishold: H must be an axes or figure graphics handle");
-      endif
-    else
-      error ("ishold: H must be an axes or figure graphics handle");
-    endif
+
+    endswitch
   endif
 
   retval = (strcmp (get (fig, "nextplot"), "add")