annotate scripts/plot/draw/stairs.m @ 19734:00e31f316a3a

Fix Matlab incompatibility of "ismatrix" (bug #42422). * data.cc (isvector): new tests * data.cc (isrow): documentation improved, new tests * data.cc (iscolumn): documentation improved, new tests * data.cc (ismatrix): is matrix now only checks the dimension due to Matlab compatibility, documentation improved, new tests * accumarray.m: use more appropriate function, than ismatrix * gradient.m: use more appropriate function, than ismatrix * num2str.m: use more appropriate functions, than ismatrix * ntsc2rgb.m: use more appropriate function, than ismatrix * condest.m: use more appropriate function, than ismatrix * expm.m: use more appropriate function, than ismatrix * onenormest.m: use more appropriate function, than ismatrix * isocolors.m: use more appropriate function, than ismatrix * isonormals.m: use more appropriate function, than ismatrix * isosurface.m: use more appropriate function, than ismatrix * __errcomm__.m: use more appropriate function, than ismatrix * __interp_cube__.m: use more appropriate function, than ismatrix * __marching_cube__.m: use more appropriate function, than ismatrix * __stem__.m: use more appropriate function, than ismatrix * stairs.m: use more appropriate function, than ismatrix * validsetargs.m: use more appropriate functions, than ismatrix * unique.m: use more appropriate functions, than ismatrix * bicg.m: additional tests for numerical value * bicgstab.m: additional tests for numerical value * cgs.m: additional tests for numerical value * gmres.m: additional tests for numerical value * qmr.m: additional tests for numerical value
author Kai T. Ohlhus <k.ohlhus@gmail.com>
date Thu, 12 Feb 2015 18:34:56 +0100
parents 4197fc428c7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19627
diff changeset
1 ## Copyright (C) 1993-2015 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
5 ## 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
6 ## 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
7 ## 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
8 ## your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
10 ## 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
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
12 ## 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
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
15 ## 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
16 ## 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
17 ## <http://www.gnu.org/licenses/>.
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 131
diff changeset
18
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
19 ## -*- texinfo -*-
10736
14af8004945d stairs.m: Add additional calling forms to documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
20 ## @deftypefn {Function File} {} stairs (@var{y})
14af8004945d stairs.m: Add additional calling forms to documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
21 ## @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
22 ## @deftypefnx {Function File} {} stairs (@dots{}, @var{style})
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17073
diff changeset
23 ## @deftypefnx {Function File} {} stairs (@dots{}, @var{prop}, @var{val}, @dots{})
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
24 ## @deftypefnx {Function File} {} stairs (@var{hax}, @dots{})
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
25 ## @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
26 ## @deftypefnx {Function File} {[@var{xstep}, @var{ystep}] =} stairs (@dots{})
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
27 ## Produce a stairstep plot.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
28 ##
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
29 ## The arguments @var{x} and @var{y} may be vectors or matrices.
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
30 ## If only one argument is given, it is taken as a vector of Y values
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
31 ## and the X coordinates are taken to be the indices of the elements.
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
32 ##
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
33 ## The style to use for the plot can be defined with a line style @var{style}
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17073
diff changeset
34 ## of the same format as the @code{plot} command.
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
35 ##
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
36 ## Multiple property/value pairs may be specified, but they must appear in
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
37 ## pairs.
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
38 ##
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
39 ## If the first argument @var{hax} is an axis handle, then plot into this axis,
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
40 ## rather than the current axis handle returned by @code{gca}.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
41 ##
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16752
diff changeset
42 ## If one output argument is requested, return a graphics handle to the
16816
12005245b645 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 16814
diff changeset
43 ## created plot. If two output arguments are specified, the data are generated
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16752
diff changeset
44 ## but not plotted. For example,
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
45 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
46 ## @example
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
47 ## stairs (x, y);
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
48 ## @end example
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
49 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
50 ## @noindent
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
51 ## and
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
52 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
53 ## @example
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6448
diff changeset
54 ## @group
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
55 ## [xs, ys] = stairs (x, y);
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
56 ## plot (xs, ys);
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6448
diff changeset
57 ## @end group
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
58 ## @end example
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
59 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
60 ## @noindent
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
61 ## are equivalent.
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17073
diff changeset
62 ## @seealso{bar, hist, plot, stem}
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
63 ## @end deftypefn
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
64
2314
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
65 ## Author: jwe
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
66
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
67 function [xs, ys] = stairs (varargin)
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
68
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
69 [hax, varargin, nargin] = __plt_get_axis_arg__ ("stairs", varargin{:});
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
70
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
71 if (nargin < 1)
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
72 print_usage ();
17211
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17126
diff changeset
73 endif
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
74
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
75 if (nargout < 2)
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
76 oldfig = [];
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
77 if (! isempty (hax))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
78 oldfig = get (0, "currentfigure");
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
79 endif
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
80 unwind_protect
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
81 hax = newplot (hax);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
82 [htmp, xxs, yys] = __stairs__ (true, varargin{:});
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
83 unwind_protect_cleanup
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
84 if (! isempty (oldfig))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
85 set (0, "currentfigure", oldfig);
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
86 endif
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
87 end_unwind_protect
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
88 if (nargout == 1)
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
89 xs = htmp;
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
90 endif
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
91 else
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
92 [~, xs, ys] = __stairs__ (false, varargin{:});
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
93 endif
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
94
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
95 endfunction
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
96
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
97 function [h, xs, ys] = __stairs__ (doplot, varargin)
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
98
9809
965487e00282 stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
99 if (nargin == 2 || ischar (varargin{2}))
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
100 y = varargin{1};
8070
3b53b25e2550 Add data sources and line series
David Bateman <dbateman@free.fr>
parents: 8056
diff changeset
101 varargin(1) = [];
19734
00e31f316a3a Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 19731
diff changeset
102 if (! isnumeric (y) || ndims (y) > 2)
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
103 error ("stairs: Y must be a numeric 2-D vector or matrix");
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
104 endif
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
105 if (isvector (y))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
106 y = y(:);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
107 endif
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
108 x = 1:rows (y);
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
109 else
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
110 x = varargin{1};
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
111 y = varargin{2};
8070
3b53b25e2550 Add data sources and line series
David Bateman <dbateman@free.fr>
parents: 8056
diff changeset
112 varargin(1:2) = [];
19734
00e31f316a3a Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 19731
diff changeset
113 if (! isnumeric (x) || ! isnumeric (y) || ndims (x) > 2 || ndims (y) > 2)
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
114 error ("stairs: X and Y must be numeric 2-D vectors or matrices");
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
115 endif
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
116 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
117
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
118 vec_x = isvector (x);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
119 if (vec_x)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
120 x = x(:);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
121 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
122
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
123 if (isvector (y))
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
124 y = y(:);
19734
00e31f316a3a Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 19731
diff changeset
125 elseif (isnumeric (y) && vec_x)
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
126 x = repmat (x, [1, columns(y)]);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
127 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
128
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
129 if (! size_equal (x, y))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
130 error ("stairs: X and Y sizes must match");
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
131 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
132
17528
1da32463b540 stairs.m: Add missing definition of nr, nc.
Rik <rik@octave.org>
parents: 17527
diff changeset
133 [nr, nc] = size (y);
1da32463b540 stairs.m: Add missing definition of nr, nc.
Rik <rik@octave.org>
parents: 17527
diff changeset
134
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
135 len = 2*nr - 1;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
136
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
137 xs = ys = zeros (len, nc);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
138
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
139 xs(1,:) = x(1,:);
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
140 ys(1,:) = y(1,:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
141
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
142 xtmp = x(2:nr,:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
143 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
144 xs(ridx,:) = xtmp;
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
145 ys(ridx,:) = y(1:nr-1,:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
146
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
147 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
148 xs(ridx,:) = xtmp;
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
149 ys(ridx,:) = y(2:nr,:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
150
8243
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
151 have_line_spec = false;
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
152 for i = 1:2:numel (varargin)
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
153 arg = varargin{i};
17462
177147bf7b55 Overhaul use of __pltopt__.m to correctly check for cellstr, not just cell.
Rik <rik@octave.org>
parents: 17433
diff changeset
154 if (ischar (arg) || iscellstr (arg))
8243
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
155 [linespec, valid] = __pltopt__ ("stairs", arg, false);
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
156 if (valid)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
157 have_line_spec = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
158 varargin(i) = [];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
159 break;
8243
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
160 endif
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
161 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
162 endfor
8243
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
163
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
164 if (doplot)
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
165 h = [];
17126
26589abbc78d Don't pass axis handle unnecessarily from high level to low level plot functions.
Rik <rik@octave.org>
parents: 17122
diff changeset
166 hold_state = get (gca (), "nextplot");
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
167 unwind_protect
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
168 for i = 1 : columns (y)
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
169
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
170 if (have_line_spec)
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
171 lc = linespec.color;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
172 if (isempty (lc))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
173 lc = __next_line_color__ ();
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
174 endif
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
175 ls = linespec.linestyle;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
176 if (isempty (ls))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
177 ls = "-";
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
178 endif
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
179 mk = linespec.marker;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
180 if (isempty (mk))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
181 mk = "none";
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
182 endif
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
183 else
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
184 lc = __next_line_color__ ();
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
185 ls = "-";
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
186 mk = "none";
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
187 endif
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
188
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
189 ## Must occur after __next_line_color__ in order to work correctly.
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
190 hg = hggroup ();
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
191 h = [h; hg];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
192 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
193
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
194 addproperty ("xdata", hg, "data", x(:,i).');
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
195 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
196
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
197 addlistener (hg, "xdata", @update_data);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
198 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
199
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
200 htmp = line (xs(:,i).', ys(:,i).', "color", lc, "linestyle", ls,
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
201 "marker", mk, "parent", hg);
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
202
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
203 addproperty ("color", hg, "linecolor", get (htmp, "color"));
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
204 addproperty ("linestyle", hg, "linelinestyle", get (htmp, "linestyle"));
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
205 addproperty ("linewidth", hg, "linelinewidth", get (htmp, "linewidth"));
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
206
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
207 addproperty ("marker", hg, "linemarker", get (htmp, "marker"));
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
208 addproperty ("markeredgecolor", hg, "linemarkeredgecolor",
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
209 get (htmp, "markeredgecolor"));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
210 addproperty ("markerfacecolor", hg, "linemarkerfacecolor",
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
211 get (htmp, "markerfacecolor"));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
212 addproperty ("markersize", hg, "linemarkersize",
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
213 get (htmp, "markersize"));
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
214
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
215 addlistener (hg, "color", @update_props);
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
216 addlistener (hg, "linestyle", @update_props);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
217 addlistener (hg, "linewidth", @update_props);
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
218 addlistener (hg, "marker", @update_props);
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
219 addlistener (hg, "markeredgecolor", @update_props);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
220 addlistener (hg, "markerfacecolor", @update_props);
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
221 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
222
17527
76614e624818 Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents: 17462
diff changeset
223 ## Matlab property, although Octave does not implement it.
76614e624818 Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents: 17462
diff changeset
224 addproperty ("hittestarea", hg, "radio", "on|{off}", "off");
76614e624818 Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents: 17462
diff changeset
225
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
226 if (! isempty (args))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
227 set (hg, args{:});
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
228 endif
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
229 endfor
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
230 unwind_protect_cleanup
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
231 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
232 end_unwind_protect
736
c8f88bd3202b [project @ 1994-09-24 03:28:05 by jwe]
jwe
parents: 245
diff changeset
233 else
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
234 h = 0;
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
235 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
236
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
237 endfunction
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
238
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
239 function update_props (h, ~)
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
240 set (get (h, "children"),
17572
7bb76a22cde1 maint: Split scripts/plot directory into 4 pieces.
Rik <rik@octave.org>
parents: 17528
diff changeset
241 {"color", "linestyle", "linewidth", "marker", ...
7bb76a22cde1 maint: Split scripts/plot directory into 4 pieces.
Rik <rik@octave.org>
parents: 17528
diff changeset
242 "markeredgecolor", "markerfacecolor", "markersize"},
7bb76a22cde1 maint: Split scripts/plot directory into 4 pieces.
Rik <rik@octave.org>
parents: 17528
diff changeset
243 get (h, {"color", "linestyle", "linewidth", "marker", ...
7bb76a22cde1 maint: Split scripts/plot directory into 4 pieces.
Rik <rik@octave.org>
parents: 17528
diff changeset
244 "markeredgecolor", "markerfacecolor", "markersize"}));
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
245 endfunction
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
246
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
247 function update_data (h, ~)
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
248 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
249 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
250
16752
d6b666e8449c Update copies consistent subset of {x,y,z}data to children of the stairs hggoup.
Ben Abbott <bpabbott@mac.com>
parents: 14872
diff changeset
251 sz = min ([size(x); size(y)]);
d6b666e8449c Update copies consistent subset of {x,y,z}data to children of the stairs hggoup.
Ben Abbott <bpabbott@mac.com>
parents: 14872
diff changeset
252 x = x(1:sz(1), 1:sz(2));
d6b666e8449c Update copies consistent subset of {x,y,z}data to children of the stairs hggoup.
Ben Abbott <bpabbott@mac.com>
parents: 14872
diff changeset
253 y = y(1:sz(1), 1:sz(2));
d6b666e8449c Update copies consistent subset of {x,y,z}data to children of the stairs hggoup.
Ben Abbott <bpabbott@mac.com>
parents: 14872
diff changeset
254
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
255 nr = length (x);
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
256 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
257 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
258
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
259 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
260 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
261
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
262 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
263 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
264 xs(ridx) = xtmp;
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
265 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
266
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
267 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
268 xs(ridx) = xtmp;
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
269 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
270
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
271 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
272 endfunction
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
273
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
274
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
275 %!demo
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
276 %! clf;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
277 %! rand_1x10_data1 = [0.073, 0.455, 0.837, 0.124, 0.426, 0.781, 0.004, 0.024, 0.519, 0.698];
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
278 %! y = rand_1x10_data1;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
279 %! stairs (y);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
280 %! title ('stairs() plot of y-data');
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
281
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
282 %!demo
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
283 %! clf;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
284 %! x = 1:10;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
285 %! rand_1x10_data2 = [0.014, 0.460, 0.622, 0.394, 0.531, 0.378, 0.466, 0.788, 0.342, 0.893];
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
286 %! y = rand_1x10_data2;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
287 %! [xs, ys] = stairs (x, y);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
288 %! plot (xs, ys);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
289 %! title ('plot() of stairs() generated data');
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
290
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
291 %!demo
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
292 %! clf;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
293 %! stairs (1:9, '-o');
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
294 %! title ('stairs() plot with linespec to modify marker');
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
295
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
296 %!demo
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
297 %! clf;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
298 %! stairs (9:-1:1, 'marker', 's', 'markersize', 10, 'markerfacecolor', 'm');
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
299 %! title ('stairs() plot with prop/val pairs to modify appearance');
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
300
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
301 %!demo
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
302 %! clf;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
303 %! N = 11;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
304 %! x = 0:(N-1);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
305 %! y = rand (1, N);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
306 %! hs = stairs (x(1), y(1));
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
307 %! axis ([1, N-1 0, 1]);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
308 %! title ('stairs plot data modified through handle');
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
309 %! for k = 2:N
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
310 %! set (hs, 'xdata', x(1:k), 'ydata', y(1:k));
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
311 %! drawnow ();
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
312 %! pause (0.2);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
313 %! end
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
314
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
315 ## Invisible figure used for tests
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
316 %!shared hf, hax
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
317 %! hf = figure ("visible", "off");
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
318 %! hax = axes;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
319
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
320 %!error stairs ()
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
321 %!error <Y must be a numeric 2-D vector> stairs (hax, {1})
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
322 %!error <Y must be a numeric 2-D vector> stairs (ones (2,2,2))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
323 %!error <X and Y must be numeric 2-D vector> stairs ({1}, 1)
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
324 %!error <X and Y must be numeric 2-D vector> stairs (1, {1})
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
325 %!error <X and Y must be numeric 2-D vector> stairs (ones (2,2,2), 1)
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
326 %!error <X and Y must be numeric 2-D vector> stairs (1, ones (2,2,2))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
327 %!error <X and Y sizes must match> stairs (1:2, 1:3)
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
328
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
329 ## Close figure used for testing
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
330 %!test
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
331 %! close (hf);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
332