annotate scripts/plot/stairs.m @ 11191:01ddaedd6ad5

Reverse changeset b1f4bdc276b6. Use all lower case for "uniformoutput" option.
author Rik <octave@nomad.inbox5.com>
date Thu, 04 Nov 2010 12:18:08 -0700
parents 14af8004945d
children a0dfd7e8e3e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
1 ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2004,
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8244
diff changeset
2 ## 2005, 2006, 2007, 2008 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
3 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
4 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
5 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
7 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
9 ## your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
10 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
14 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
15 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
16 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
18 ## <http://www.gnu.org/licenses/>.
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 131
diff changeset
19
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
20 ## -*- texinfo -*-
10736
14af8004945d stairs.m: Add additional calling forms to documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
21 ## @deftypefn {Function File} {} stairs (@var{y})
14af8004945d stairs.m: Add additional calling forms to documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
22 ## @deftypefnx {Function File} {} stairs (@var{x}, @var{y})
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
23 ## @deftypefnx {Function File} {} stairs (@dots{}, @var{style})
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
24 ## @deftypefnx {Function File} {} stairs (@dots{}, @var{prop}, @var{val})
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
25 ## @deftypefnx {Function File} {} stairs (@var{h}, @dots{})
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
26 ## @deftypefnx {Function File} {@var{h} =} stairs (@dots{})
10736
14af8004945d stairs.m: Add additional calling forms to documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
27 ## @deftypefnx {Function File} {[@var{xstep}, @var{ystep}] =} stairs (@dots{})
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6448
diff changeset
28 ## Produce a stairstep plot. The arguments may be vectors or matrices.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
29 ##
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
30 ## If only one argument is given, it is taken as a vector of y-values
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
31 ## and the x coordinates are taken to be the indices of the elements.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
32 ##
10736
14af8004945d stairs.m: Add additional calling forms to documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
33 ## If one output argument is requested, return a graphics handle to the plot.
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
34 ## If two output arguments are specified, the data are generated but
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
35 ## not plotted. For example,
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
36 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
37 ## @example
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
38 ## stairs (x, y);
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
39 ## @end example
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
40 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
41 ## @noindent
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
42 ## and
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
43 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
44 ## @example
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6448
diff changeset
45 ## @group
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
46 ## [xs, ys] = stairs (x, y);
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
47 ## plot (xs, ys);
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6448
diff changeset
48 ## @end group
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
49 ## @end example
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
50 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
51 ## @noindent
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
52 ## are equivalent.
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5307
diff changeset
53 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
6448
2110cc251779 [project @ 2007-03-24 02:47:36 by jwe]
jwe
parents: 6257
diff changeset
54 ## bar, xlabel, ylabel, title}
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
55 ## @end deftypefn
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
56
2314
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
57 ## Author: jwe
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
58
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
59 function [xs, ys] = stairs (varargin)
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
60
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
61 [ax, varargin, nargin] = __plt_get_axis_arg__ ("stairs", varargin{:});
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
62
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
63 if (nargin < 1)
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
64 print_usage ();
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
65 else
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
66 if (nargout > 1)
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
67 [h, xs, ys] = __stairs__ (false, varargin{:});
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
68 else
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
69 oldax = gca ();
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
70 unwind_protect
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
71 axes (ax);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
72 newplot ();
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
73 [h, xxs, yys] = __stairs__ (true, varargin{:});
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
74 unwind_protect_cleanup
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
75 axes (oldax);
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
76 end_unwind_protect
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
77 endif
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
78 if (nargout == 1)
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
79 xs = h;
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
80 endif
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
81 endif
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
82 endfunction
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
83
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
84 function [h, xs, ys] = __stairs__ (doplot, varargin)
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
85
9809
965487e00282 stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
86 if (nargin == 2 || ischar (varargin{2}))
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
87 y = varargin {1};
8070
3b53b25e2550 Add data sources and line series
David Bateman <dbateman@free.fr>
parents: 8056
diff changeset
88 varargin(1) = [];
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
89 if (ismatrix (y))
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
90 if (isvector (y))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
91 y = y(:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
92 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
93 x = 1:rows (y);
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
94 endif
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
95 else
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
96 x = varargin{1};
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
97 y = varargin{2};
8070
3b53b25e2550 Add data sources and line series
David Bateman <dbateman@free.fr>
parents: 8056
diff changeset
98 varargin(1:2) = [];
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
99 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
100
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
101 if (ndims (x) > 2 || ndims (y) > 2)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
102 error ("stairs: expecting 2-d arguments");
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
103 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
104
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
105 vec_x = isvector (x);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
106
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
107 if (vec_x)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
108 x = x(:);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
109 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
110
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
111 if (isvector (y))
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
112 y = y(:);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
113 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
114
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
115 if (ismatrix (y))
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
116 [nr, nc] = size (y);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
117 if (vec_x)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
118 x = repmat (x, [1, nc]);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
119 else
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
120 [x_nr, x_nc] = size (x);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
121 if (x_nr != nr || x_nc != nc)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
122 error ("stairs: argument size mismatch");
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
123 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
124 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
125 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
126
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
127 len = 2*nr - 1;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
128
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
129 xs = ys = zeros (len, nc);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
130
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
131 xs(1,:) = x(1,:);
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
132 ys(1,:) = y(1,:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
133
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
134 xtmp = x(2:nr,:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
135 ridx = 2:2:len-1;
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
136 xs(ridx,:) = xtmp;
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
137 ys(ridx,:) = y(1:nr-1,:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
138
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
139 ridx = 3:2:len;
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
140 xs(ridx,:) = xtmp;
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
141 ys(ridx,:) = y(2:nr,:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
142
8243
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
143 have_line_spec = false;
8244
ca410b015910 Opps with previous patch
David Bateman <dbateman@free.fr>
parents: 8243
diff changeset
144 for i = 1 : length (varargin)
8243
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
145 arg = varargin {i};
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
146 if ((ischar (arg) || iscell (arg)) && ! have_line_spec)
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
147 [linespec, valid] = __pltopt__ ("stairs", arg, false);
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
148 if (valid)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
149 have_line_spec = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
150 varargin(i) = [];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
151 break;
8243
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
152 endif
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
153 endif
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
154 endfor
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
155
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
156 if (doplot)
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
157 h = [];
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
158 unwind_protect
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
159 hold_state = get (gca (), "nextplot");
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
160 for i = 1 : size(y, 2)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
161 hg = hggroup ();
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
162 h = [h; hg];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
163 args = __add_datasource__ ("stairs", hg, {"x", "y"}, varargin{:});
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
164
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
165 addproperty ("xdata", hg, "data", x(:,i).');
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
166 addproperty ("ydata", hg, "data", y(:,i).');
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
167
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
168 addlistener (hg, "xdata", @update_data);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
169 addlistener (hg, "ydata", @update_data);
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
170
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
171 if (have_line_spec)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
172 tmp = line (xs(:,i).', ys(:,i).', "color", linespec.color,
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
173 "parent", hg);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
174 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
175 tmp = line (xs(:,i).', ys(:,i).', "color", __next_line_color__ (),
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
176 "parent", hg);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
177 endif
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8070
diff changeset
178
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
179 addproperty ("color", hg, "linecolor", get (tmp, "color"));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
180 addproperty ("linewidth", hg, "linelinewidth", get (tmp, "linewidth"));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
181 addproperty ("linestyle", hg, "linelinestyle", get (tmp, "linestyle"));
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
182
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
183 addproperty ("marker", hg, "linemarker", get (tmp, "marker"));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
184 addproperty ("markerfacecolor", hg, "linemarkerfacecolor",
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
185 get (tmp, "markerfacecolor"));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
186 addproperty ("markeredgecolor", hg, "linemarkeredgecolor",
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
187 get (tmp, "markeredgecolor"));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
188 addproperty ("markersize", hg, "linemarkersize",
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
189 get (tmp, "markersize"));
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
190
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
191 addlistener (hg, "color", @update_props);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
192 addlistener (hg, "linewidth", @update_props);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
193 addlistener (hg, "linestyle", @update_props);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
194 addlistener (hg, "marker", @update_props);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
195 addlistener (hg, "markerfacecolor", @update_props);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
196 addlistener (hg, "markeredgecolor", @update_props);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
197 addlistener (hg, "markersize", @update_props);
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8070
diff changeset
198
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
199 if (! isempty (args))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
200 set (hg, args{:});
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
201 endif
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
202 endfor
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
203 unwind_protect_cleanup
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
204 set (gca (), "nextplot", hold_state);
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
205 end_unwind_protect
736
c8f88bd3202b [project @ 1994-09-24 03:28:05 by jwe]
jwe
parents: 245
diff changeset
206 else
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
207 h = 0;
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
208 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
209
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
210 endfunction
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
211
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
212 %!demo
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
213 %! x = 1:10;
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
214 %! y = rand (1, 10);
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
215 %! stairs (x, y);
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
216
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
217 %!demo
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
218 %! x = 1:10;
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
219 %! y = rand (1, 10);
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
220 %! [xs, ys] = stairs (x, y);
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
221 %! plot (xs, ys);
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
222
9809
965487e00282 stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
223 %!demo
965487e00282 stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
224 %! stairs (1:9);
965487e00282 stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
225
965487e00282 stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
226 %!demo
965487e00282 stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
227 %! [xs, ys] = stairs (9:-1:1);
965487e00282 stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
228 %! plot (xs, ys);
965487e00282 stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
229
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
230 function update_props (h, d)
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
231 set (get (h, "children"), "color", get (h, "color"),
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
232 "linewidth", get (h, "linewidth"),
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
233 "linestyle", get (h, "linestyle"),
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
234 "marker", get (h, "marker"),
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
235 "markerfacecolor", get (h, "markerfacecolor"),
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
236 "markeredgecolor", get (h, "markeredgecolor"),
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
237 "markersize", get (h, "markersize"));
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
238 endfunction
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
239
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
240 function update_data (h, d)
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
241 x = get (h, "xdata");
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
242 y = get (h, "ydata");
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
243
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
244 nr = length (x);
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
245 len = 2 * nr - 1;
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
246 xs = ys = zeros (1, len);
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
247
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
248 xs(1) = x(1);
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
249 ys(1) = y(1);
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
250
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
251 xtmp = x(2:nr);
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
252 ridx = 2:2:len-1;
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
253 xs(ridx) = xtmp;
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
254 ys(ridx) = y(1:nr-1);
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
255
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
256 ridx = 3:2:len;
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
257 xs(ridx) = xtmp;
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
258 ys(ridx) = y(2:nr);
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
259
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
260 set (get (h, "children"), "xdata", xs, "ydata", ys);
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
261 endfunction