Mercurial > octave-nkf
changeset 13033:d0dccc6dd4e7 stable
plotyy.m: Always restore current axes when done.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Thu, 01 Sep 2011 11:19:52 -0400 |
parents | d2997525fcb6 |
children | fa0827db4d5d |
files | scripts/plot/plotyy.m |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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"))