# HG changeset patch # User Ben Abbott # Date 1314890392 14400 # Node ID d0dccc6dd4e7c59c2e816f93fc83603c36b7583c # Parent d2997525fcb6343609cfca2e1df9ac0da6cbd53e plotyy.m: Always restore current axes when done. diff -r d2997525fcb6 -r d0dccc6dd4e7 scripts/plot/plotyy.m --- a/scripts/plot/plotyy.m Wed Aug 31 18:19:17 2011 -0400 +++ b/scripts/plot/plotyy.m Thu Sep 01 11:19:52 2011 -0400 @@ -70,6 +70,7 @@ else error ("plotyy: expecting first argument to be axes handle"); endif + oldh = gca (); else f = get (0, "currentfigure"); if (isempty (f)) @@ -93,17 +94,18 @@ elseif (isempty (ax)) ax(1) = axes (); ax(2) = axes (); + ca = ax(2); endif if (nargin < 2) varargin = {}; endif + oldh = ca; endif if (nargin < 4) print_usage (); endif - oldh = gca (); unwind_protect [ax, h1, h2] = __plotyy__ (ax, varargin{:}); unwind_protect_cleanup @@ -241,6 +243,15 @@ %! plotyy (x, 10*sin(2*pi*x), x, cos(2*pi*x)) %! axis square +%!demo +%! clf +%! x = linspace (-1, 1, 201); +%! subplot (1, 1, 1); +%! hax = plotyy (x, sin(pi*x), x, cos(pi*x)); +%! ylabel ("Blue and on the Left") +%! ylabel (hax(2), "Green and on the Right") +%! xlabel ("xlabel") + function deleteplotyy (h, d, ax2, t2) if (ishandle (ax2) && strcmp (get (ax2, "type"), "axes") && (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))