comparison scripts/plot/comet.m @ 17060:2d17dbdf6b7d

comet.m, comet3.m: Update to use new __plt_get_axis_arg__. * scripts/plot/comet.m, scripts/plot/comet3.m: Update to use new __plt_get_axis_arg__.
author Rik <rik@octave.org>
date Wed, 24 Jul 2013 23:12:46 -0700
parents 64e7bb01fce2
children eaab03308c0b
comparison
equal deleted inserted replaced
17059:c935a0db31c6 17060:2d17dbdf6b7d
37 ## Author: Ben Abbott bpabbott@mac.com 37 ## Author: Ben Abbott bpabbott@mac.com
38 ## Created: 2008-09-21 38 ## Created: 2008-09-21
39 39
40 function comet (varargin) 40 function comet (varargin)
41 41
42 [h, varargin, nargin] = __plt_get_axis_arg__ ("comet", varargin{:}); 42 [hax, varargin, nargin] = __plt_get_axis_arg__ ("comet", varargin{:});
43 43
44 if (nargin == 0) 44 if (nargin == 0)
45 print_usage (); 45 print_usage ();
46 elseif (nargin == 1) 46 elseif (nargin == 1)
47 y = varargin{1}; 47 y = varargin{1};
55 x = varargin{1}; 55 x = varargin{1};
56 y = varargin{2}; 56 y = varargin{2};
57 p = varargin{3}; 57 p = varargin{3};
58 endif 58 endif
59 59
60 oldh = gca (); 60 oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
61 unwind_protect 61 unwind_protect
62 axes (h); 62 hax = newplot (hax);
63 newplot (); 63 limits = [min(x), max(x), min(y), max(y)];
64 theaxis = [min(x), max(x), min(y), max(y)];
65 num = numel (y); 64 num = numel (y);
66 dn = round (num/10); 65 dn = round (num/10);
67 for n = 1:(num+dn); 66 for n = 1:(num+dn);
68 m = n - dn; 67 m = n - dn;
69 m = max ([m, 1]); 68 m = max ([m, 1]);
70 k = min ([n, num]); 69 k = min ([n, num]);
71 h = plot (x(1:m), y(1:m), "r", x(m:k), y(m:k), "g", x(k), y(k), "ob"); 70 plot (hax, x(1:m), y(1:m), "r", x(m:k), y(m:k), "g", x(k), y(k), "ob");
72 axis (theaxis); 71 axis (hax, limits);
73 drawnow (); 72 drawnow ();
74 pause (p); 73 pause (p);
75 endfor 74 endfor
76 unwind_protect_cleanup 75 unwind_protect_cleanup
77 axes (oldh); 76 if (! isempty (oldfig))
77 set (0, "currentfigure", oldfig);
78 endif
78 end_unwind_protect 79 end_unwind_protect
79 80
80 endfunction 81 endfunction
81 82
82 83