changeset 28787:92beaab911c2

maint: merge stable to default.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 23 Sep 2020 21:23:32 +0200
parents 02c2d6500c1f (current diff) 396d3e1df78b (diff)
children aba2c4eadb83
files scripts/plot/util/subplot.m
diffstat 1 files changed, 24 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/subplot.m	Wed Sep 23 20:41:57 2020 +0200
+++ b/scripts/plot/util/subplot.m	Wed Sep 23 21:23:32 2020 +0200
@@ -249,15 +249,31 @@
             continue;
           endif
 
-          ## Check if this axes is a subplot with the same layout and
-          ## index as the requested one
-          rcn = getappdata (child, "__subplotrcn__");
+          if (! replace_axes)
+            if (isappdata (child, "__subplotposition__"))
+              objpos = getappdata (child, "__subplotposition__");
+            else
+              objpos = get (child, "position");
+            endif
+            if (all (abs (objpos - pos) < eps))
+              ## If the new axes are in exactly the same position
+              ## as an existing axes object, or if they share the same
+              ## appdata "__subplotposition__", use the existing axes.
+              found = true;
+              hsubplot = child;
+            else
+              ## Check if this axes is a subplot with the same layout and
+              ## index as the requested one
+              rcn = getappdata (child, "__subplotrcn__");
+              if (all (size (rcn) == [1 3])
+                  && rcn{1} == rows && rcn{2} == cols && all (rcn{3} == index))
+                found = true;
+                hsubplot = child;
+              endif
+            endif
+          endif
 
-          if (! replace_axes && all (size (rcn) == [1 3])
-              && rcn{1} == rows && rcn{2} == cols && all (rcn{3} == index))
-            found = true;
-            hsubplot = child;
-          else
+          if (! found)
             ## If the new axes overlap an old axes object, delete the old axes.
             objpos = get (child, "position");