Mercurial > hg > octave-lyh
changeset 11994:f944142010ce release-3-2-x
plotyy.m: Fix compatibility with subplot.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Tue, 16 Jun 2009 06:43:56 +0200 |
parents | 9caef5712f40 |
children | 1ffb54887c42 |
files | scripts/ChangeLog scripts/plot/plotyy.m |
diffstat | 2 files changed, 40 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2009-06-14 Ben Abbott <bpabbott@mac.com> + + * plot/plotyy.m: Fix compatibility with subplot, add listeners for + dataaspectratio, and add a demo. + 2009-06-14 Eric Chassande-Mottin <echassandemottin@gmail.com> * plot/plotyy.m: Correct behavior when there is no currentfigure.
--- a/scripts/plot/plotyy.m +++ b/scripts/plot/plotyy.m @@ -75,7 +75,14 @@ if (isempty (f)) f = figure (); endif - ax = get (f, "children"); + ca = get (f, "currentaxes"); + if (isempty (ca)) + ax = []; + elseif (strcmp (get (ca, "tag"), "plotyy")); + ax = get (ca, "__plotyy_axes__"); + else + ax = ca; + endif if (length (ax) > 2) for i = 3 : length (ax) delete (ax (i)); @@ -175,11 +182,17 @@ addlistener (ax(2), "position", {@update_position, ax(1)}); addlistener (ax(1), "view", {@update_position, ax(2)}); addlistener (ax(2), "view", {@update_position, ax(1)}); + addlistener (ax(1), "dataaspectratio", {@update_position, ax(2)}); + addlistener (ax(2), "dataaspectratio", {@update_position, ax(1)}); ## Tag the plotyy axes, so we can use that information ## not to mirror the y axis tick marks set (ax, "tag", "plotyy") + ## Store the axes handles for the sister axes. + addproperty ("__plotyy_axes__", ax(1), "data", ax); + addproperty ("__plotyy_axes__", ax(2), "data", ax); + endfunction %!demo @@ -192,6 +205,19 @@ %! ylabel (ax(1), "Axis 1"); %! ylabel (ax(2), "Axis 2"); +%!demo +%! clf +%! x = linspace (-1, 1, 201); +%! subplot (2, 2, 1) +%! plotyy (x, sin(pi*x), x, 10*cos(pi*x)) +%! subplot (2, 2, 2) +%! surf (peaks (25)) +%! subplot (2, 2, 3) +%! contour (peaks (25)) +%! subplot (2, 2, 4) +%! plotyy (x, 10*sin(2*pi*x), x, cos(2*pi*x)) +%! axis square + function deleteplotyy (h, d, ax2, t2) if (ishandle (ax2) && strcmp (get (ax2, "type"), "axes") && (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off")) && @@ -210,10 +236,16 @@ recursion = true; position = get (h, "position"); view = get (h, "view"); + dataaspectratio = get (h, "dataaspectratio"); oldposition = get (ax2, "position"); oldview = get (ax2, "view"); - if (! (isequal (position, oldposition) && isequal (view, oldview))) - set (ax2, "position", position, "view", view); + olddataaspectratio = get (ax2, "dataaspectratio"); + if (! (isequal (position, oldposition) + && isequal (view, oldview) + && isequal (dataaspectratio, olddataaspectratio))) + set (ax2, "position", position, + "view", view, + "dataaspectratio", dataaspectratio); endif unwind_protect_cleanup recursion = false;