changeset 31032:0938366560cf stable

subplot.m: Avoid error when mixing rcn and "position" calling form (bug #62526). * scripts/plot/util/subplot.m: When called without "rows", "cols", and "index" arguments, don't check if existing axes have matching "__subplotrcn__" value.
author Markus Mützel <markus.muetzel@gmx.de>
date Thu, 26 May 2022 19:30:35 +0200
parents 9504d582b2c6
children bb9c7512e090 399925c27b7c
files scripts/plot/util/subplot.m
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/subplot.m	Thu May 26 18:25:51 2022 +0200
+++ b/scripts/plot/util/subplot.m	Thu May 26 19:30:35 2022 +0200
@@ -288,7 +288,7 @@
               ## appdata "__subplotposition__", use the existing axes.
               found = true;
               hsubplot = child;
-            else
+            elseif (exist ("rows", "var"))
               ## Check if this axes is a subplot with the same layout and
               ## index as the requested one
               rcn = getappdata (child, "__subplotrcn__");
@@ -648,6 +648,18 @@
 %!   delete (hf);
 %! end_unwind_protect
 
+## Mixed rcn and position mode
+%!test <*62526>
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   h1 = subplot (2, 2, 1);
+%!   h2 = subplot ("position", [0.5 0.5 0.3 0.3]);
+%!   h3 = subplot (223);
+%!   assert (get (hf, "children"), [h3; h2; h1]);
+%! unwind_protect_cleanup
+%!   delete (hf);
+%! end_unwind_protect
+
 ## Align mode
 %!test
 %! hf = figure ("visible", "off");