changeset 8237:52f2fba4f3f8

Test that an axis handle actually is one before setting it in plotyy
author David Bateman <dbateman@free.fr>
date Mon, 20 Oct 2008 13:22:17 +0100
parents 7799d8c38312
children 6ef647359f07
files scripts/ChangeLog scripts/plot/plotyy.m
diffstat 2 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Fri Oct 17 16:06:32 2008 +0100
+++ b/scripts/ChangeLog	Mon Oct 20 13:22:17 2008 +0100
@@ -1,3 +1,8 @@
+2008-10-20  David Bateman  <dbateman@free.fr>
+
+	* plot/plotyy.m: Test that an axes handle actually is one before
+	setting it.
+
 2008-10-17  David Bateman  <dbateman@free.fr>
 
 	* plot/__plt_get_axis_arg__.m: Exclude non-numeric and root figure
--- a/scripts/plot/plotyy.m	Fri Oct 17 16:06:32 2008 +0100
+++ b/scripts/plot/plotyy.m	Mon Oct 20 13:22:17 2008 +0100
@@ -99,7 +99,10 @@
   unwind_protect
     [ax, h1, h2] = __plotyy__ (ax, varargin{:});
   unwind_protect_cleanup
-    axes (oldh);
+    ## Only change back to the old axis if we didn't delete it
+    if (ishandle(oldh) && strcmp (get (oldh, "type"), "axes"))
+      axes (oldh);
+    endif
   end_unwind_protect
 
   if (nargout > 0)
@@ -124,7 +127,11 @@
 
   xlim = [min([x1(:); x2(:)]), max([x1(:); x2(:)])];
 
-  axes (ax(1));
+  if (ishandle(ax(1)) && strcmp (get (ax(1), "type"), "axes"))
+    axes (ax(1));
+  else
+    ax(1) = axes ();
+  endif
   newplot ();
   h1 = feval (fun1, x1, y1);
 
@@ -133,7 +140,12 @@
 
   cf = gcf ();
   set (cf, "nextplot", "add");
-  axes (ax(2));
+
+  if (ishandle(ax(2)) && strcmp (get (ax(2), "type"), "axes"))
+    axes (ax(2));
+  else
+    ax(2) = axes ();
+  endif
   newplot ();
 
   colors = get (ax(1), "colororder");