Skip to content

Commit 4fc7781

Browse files
author
Rik
committed
ishold.m: Code cleanup of variable names.
* ishold.m: Rename variable "fig" to "hfig" and "ax" to "hax" to emphasize that they hold graphics handles. Use numel() in preference to length(). Add one more case to existing BIST test.
1 parent 057b3c1 commit 4fc7781

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

scripts/plot/util/ishold.m

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,30 @@
3838
function tf = ishold (h)
3939

4040
if (nargin == 0)
41-
fig = gcf ();
42-
ax = get (fig, "currentaxes");
41+
hfig = gcf ();
42+
hax = get (hfig, "currentaxes");
4343
else
4444
if (! ishghandle (h))
4545
error ("ishold: H must be an axes or figure graphics handle");
4646
endif
4747

4848
switch (get (h, "type"))
4949
case "figure"
50-
fig = h;
51-
ax = get (fig, "currentaxes");
50+
hfig = h;
51+
hax = get (hfig, "currentaxes");
5252

5353
case "axes"
54-
ax = h;
55-
fig = ancestor (ax, "figure");
54+
hax = h;
55+
hfig = ancestor (hax, "figure");
5656

5757
otherwise
5858
error ("ishold: H must be an axes or figure graphics handle");
5959

6060
endswitch
6161
endif
6262

63-
tf = (strcmp (get (fig, "nextplot"), "add")
64-
&& ! isempty (ax) && strcmp (get (ax, "nextplot"), "add"));
63+
tf = (strcmp (get (hfig, "nextplot"), "add")
64+
&& ! isempty (hax) && strcmp (get (hax, "nextplot"), "add"));
6565

6666
endfunction
6767

@@ -83,8 +83,11 @@
8383
%! assert (get (gca, "NextPlot"), "add");
8484
%! assert (get (hf, "NextPlot"), "add");
8585
%! p = fill ([0 1 1], [0 0 1],"black");
86-
%! assert (length (get (hf, "children")), 1);
87-
%! assert (length (get (gca, "children")), 2);
86+
%! assert (numel (get (hf, "children")), 1);
87+
%! assert (numel (get (gca, "children")), 2);
88+
%! set (hf, "NextPlot", "new");
89+
%! assert (! ishold);
90+
%! assert (! ishold (gca));
8891
%! unwind_protect_cleanup
8992
%! close (hf);
9093
%! end_unwind_protect

0 commit comments

Comments
 (0)