Mercurial > hg > octave-nkf
changeset 16752:d6b666e8449c
Update copies consistent subset of {x,y,z}data to children of the stairs hggoup.
(Bug # 39234)
* scripts/plot/stairs.m: When a listener for {x,y,z}data triggers an update,
copy {x,y,z}data(1:M,1:N) to the hggroup's children, where M/N are the
minimum number of rows/columns among the matrices, {x,y,z}data. Add demo.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Wed, 12 Jun 2013 20:25:36 +0800 |
parents | 92811d110839 |
children | f8f35ddc49a2 |
files | scripts/plot/stairs.m |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/stairs.m +++ b/scripts/plot/stairs.m @@ -233,6 +233,19 @@ %! [xs, ys] = stairs (9:-1:1); %! plot (xs, ys); +%!demo +%! clf; +%! N = 11; +%! x = 0:(N-1); +%! y = rand (1, N); +%! hs = stairs (x(1), y(1)); +%! set (gca (), 'xlim', [1, N-1], 'ylim', [0, 1]); +%! for k=2:N +%! set (hs, 'xdata', x(1:k), 'ydata', y(1:k)) +%! drawnow (); +%! pause (0.2); +%! end + function update_props (h, d) set (get (h, "children"), "color", get (h, "color"), @@ -248,6 +261,10 @@ x = get (h, "xdata"); y = get (h, "ydata"); + sz = min ([size(x); size(y)]); + x = x(1:sz(1), 1:sz(2)); + y = y(1:sz(1), 1:sz(2)); + nr = length (x); len = 2 * nr - 1; xs = ys = zeros (1, len);