# HG changeset patch # User David Bateman # Date 1224505337 -3600 # Node ID 52f2fba4f3f8ce1917d485253ce99667588516d2 # Parent 7799d8c383124124123ea43b5a4468a14fff3125 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 + + * plot/plotyy.m: Test that an axes handle actually is one before + setting it. + 2008-10-17 David Bateman * 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");