octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: additional plotyy observation


From: David Bateman
Subject: Re: additional plotyy observation
Date: Mon, 20 Oct 2008 15:13:00 +0100
User-agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724)

My memory is that this used to work before it was applied.. So I imagine that something in newplot, or the graphics handles code changed with the deletion of the axes.. In fact it shouldn't have previously worked as the second call to plotyy will try and plot into an axis that was deleted with the plotyy callback. The solution is just to check whether an axis handle really is an axis handle before using it. The attached patch that I commit does this.

Cheers
David


--
David Bateman                                address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob) 91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax) The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary

# HG changeset patch
# User David Bateman <address@hidden>
# Date 1224505337 -3600
# Node ID c7693fa1906bb33cc1dc286a00d7fd6547462216
# Parent  6c85c245b7a7598a43301770ada9f26cff8fa8d4
Test that an axis handle actually is one before setting it in plotyy

diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-20  David Bateman  <address@hidden>
+
+       * plot/plotyy.m: Test that an axes handle actually is one before
+       setting it.
+
 2008-10-17  David Bateman  <address@hidden>
 
        * plot/__plt_get_axis_arg__.m: Exclude non-numeric and root figure
diff --git a/scripts/plot/plotyy.m b/scripts/plot/plotyy.m
--- a/scripts/plot/plotyy.m
+++ b/scripts/plot/plotyy.m
@@ -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");

reply via email to

[Prev in Thread] Current Thread [Next in Thread]