annotate scripts/plot/draw/stairs.m @ 32074:03fe0b635d2e

quiver/quiver3: Overhaul input processing, validation, and add BISTs. * scripts/plot/draw/private/__quiver__.m: Overhaul numeric input validation. Simplify input classification using numeric input count switch statements and avoid quiver3 miscount due to scale factor. Add error messages for all valid numeric input combinations including vector x,y,z and scale factor. Move newplot command from quiver/quiver3 into __quiver__ after numeric input validation. Add hax as an output argument to return any changes back to calling function. * scripts/plot/draw/quiver.m: Remove newplot call. Update __quiver__ call to include hax as a return variable. Update docstring with note that line style and name-value pairs can both be provided but linstyle must appear first. Add BISTs to check standard inputs with single and multiple arrows, arrowhead shape, vector and array inputs, proper treatment of scaling factor "off", some simple input styles, and input validation BISTs to cover all numeric input errors. Added known failing BIST for linestyle+pair arrowhead showing when it should stay off (bug #64143). * scripts/plot/draw/quiver3.m: Remove newplot call. Update __quiver__ call to include hax as a return variable. Update docstring with note that line style and name-value pairs can both be provided but linstyle must appear first. Add BISTs to check standard inputs with single and multiple arrows, vector and array inputs, and input validation BISTs to cover all numeric input errors. * etc/NEWS.9.md: Update quiver/quiver3 improvement description under General Improvements.
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Wed, 03 May 2023 22:52:33 -0400
parents 597f3ee61a48
children 2e484f9f1f18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
31706
597f3ee61a48 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30875
diff changeset
3 ## Copyright (C) 1993-2023 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27898
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
7 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
8 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24432
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24432
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22366
diff changeset
13 ## (at your option) any later version.
2313
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 ## 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
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22366
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22366
diff changeset
18 ## GNU General Public License for more details.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
19 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
20 ## 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
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24432
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 131
diff changeset
25
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19700
diff changeset
27 ## @deftypefn {} {} stairs (@var{y})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19700
diff changeset
28 ## @deftypefnx {} {} stairs (@var{x}, @var{y})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19700
diff changeset
29 ## @deftypefnx {} {} stairs (@dots{}, @var{style})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19700
diff changeset
30 ## @deftypefnx {} {} stairs (@dots{}, @var{prop}, @var{val}, @dots{})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19700
diff changeset
31 ## @deftypefnx {} {} stairs (@var{hax}, @dots{})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19700
diff changeset
32 ## @deftypefnx {} {@var{h} =} stairs (@dots{})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19700
diff changeset
33 ## @deftypefnx {} {[@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
34 ## Produce a stairstep plot.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
35 ##
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
36 ## 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
37 ## If only one argument is given, it is taken as a vector of Y values
24320
174a4426d441 stairs.m: Add example @code section showing what "indices of elements" means.
Rik <rik@octave.org>
parents: 23219
diff changeset
38 ## and the X coordinates are taken to be the indices of the elements
174a4426d441 stairs.m: Add example @code section showing what "indices of elements" means.
Rik <rik@octave.org>
parents: 23219
diff changeset
39 ## (@code{@var{x} = 1:numel (@var{y})}).
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
40 ##
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
41 ## 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
42 ## 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
43 ##
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
44 ## Multiple property/value pairs may be specified, but they must appear in
29668
f17b1f0141ed doc: Grammarcheck documentation ahead of 6.3 release.
Rik <rik@octave.org>
parents: 29358
diff changeset
45 ## pairs. The full list of properties is documented at
28733
9342688e86b4 Updated property references for text and graphics functions (bug #50247)
Nicholas R. Jankowski <jankowskin@asme.org>
parents: 27923
diff changeset
46 ## @ref{Line Properties}.
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
47 ##
24431
0c6cedafc71e doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents: 24320
diff changeset
48 ## If the first argument @var{hax} is an axes handle, then plot into this axes,
0c6cedafc71e doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents: 24320
diff changeset
49 ## rather than the current axes returned by @code{gca}.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
50 ##
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16752
diff changeset
51 ## 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
52 ## 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
53 ## but not plotted. For example,
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
54 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
55 ## @example
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
56 ## stairs (x, y);
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
57 ## @end example
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
58 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
59 ## @noindent
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
60 ## and
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
61 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
62 ## @example
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6448
diff changeset
63 ## @group
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
64 ## [xs, ys] = stairs (x, y);
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
65 ## plot (xs, ys);
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6448
diff changeset
66 ## @end group
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
67 ## @end example
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
68 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
69 ## @noindent
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
70 ## are equivalent.
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17073
diff changeset
71 ## @seealso{bar, hist, plot, stem}
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
72 ## @end deftypefn
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
73
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
74 function [xstep, ystep] = stairs (varargin)
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
75
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
76 [hax, varargin, nargin] = __plt_get_axis_arg__ ("stairs", varargin{:});
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
77
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
78 if (nargin < 1)
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
79 print_usage ();
17211
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17126
diff changeset
80 endif
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
81
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
82 if (nargout < 2)
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
83 oldfig = [];
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
84 if (! isempty (hax))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
85 oldfig = get (0, "currentfigure");
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
86 endif
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
87 unwind_protect
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
88 hax = newplot (hax);
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
89 htmp = __stairs__ (true, varargin{:});
22366
837df5db5710 Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents: 22323
diff changeset
90
837df5db5710 Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents: 22323
diff changeset
91 if (! ishold ())
837df5db5710 Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents: 22323
diff changeset
92 set (hax, "box", "on");
837df5db5710 Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents: 22323
diff changeset
93 endif
837df5db5710 Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents: 22323
diff changeset
94
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
95 unwind_protect_cleanup
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
96 if (! isempty (oldfig))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
97 set (0, "currentfigure", oldfig);
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
98 endif
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
99 end_unwind_protect
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
100 if (nargout == 1)
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
101 xstep = htmp;
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
102 endif
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
103 else
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
104 [~, xstep, ystep] = __stairs__ (false, varargin{:});
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
105 endif
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
106
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
107 endfunction
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
108
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
109 function [h, xs, ys] = __stairs__ (doplot, varargin)
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
110
9809
965487e00282 stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
111 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
112 y = varargin{1};
8070
3b53b25e2550 Add data sources and line series
David Bateman <dbateman@free.fr>
parents: 8056
diff changeset
113 varargin(1) = [];
19700
00e31f316a3a Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 19697
diff changeset
114 if (! isnumeric (y) || ndims (y) > 2)
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
115 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
116 endif
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
117 if (isvector (y))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
118 y = y(:);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
119 endif
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
120 x = 1:rows (y);
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
121 else
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
122 x = varargin{1};
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
123 y = varargin{2};
8070
3b53b25e2550 Add data sources and line series
David Bateman <dbateman@free.fr>
parents: 8056
diff changeset
124 varargin(1:2) = [];
19700
00e31f316a3a Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 19697
diff changeset
125 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
126 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
127 endif
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
128 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
129
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
130 vec_x = isvector (x);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
131 if (vec_x)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
132 x = x(:);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
133 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
134
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
135 if (isvector (y))
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
136 y = y(:);
19700
00e31f316a3a Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 19697
diff changeset
137 elseif (isnumeric (y) && vec_x)
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
138 x = repmat (x, [1, columns(y)]);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
139 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
140
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
141 if (! size_equal (x, y))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
142 error ("stairs: X and Y sizes must match");
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
143 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
144
17528
1da32463b540 stairs.m: Add missing definition of nr, nc.
Rik <rik@octave.org>
parents: 17527
diff changeset
145 [nr, nc] = size (y);
1da32463b540 stairs.m: Add missing definition of nr, nc.
Rik <rik@octave.org>
parents: 17527
diff changeset
146
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
147 len = 2*nr - 1;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
148
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
149 xs = ys = zeros (len, nc);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
150
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
151 xs(1,:) = x(1,:);
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
152 ys(1,:) = y(1,:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
153
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
154 xtmp = x(2:nr,:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
155 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
156 xs(ridx,:) = xtmp;
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
157 ys(ridx,:) = y(1:nr-1,:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
158
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
159 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
160 xs(ridx,:) = xtmp;
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
161 ys(ridx,:) = y(2:nr,:);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
162
8243
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
163 have_line_spec = false;
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
164 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
165 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
166 if (ischar (arg) || iscellstr (arg))
8243
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
167 [linespec, valid] = __pltopt__ ("stairs", arg, false);
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
168 if (valid)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
169 have_line_spec = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
170 varargin(i) = [];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
171 break;
8243
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
172 endif
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
173 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
174 endfor
8243
ec4d9d657b17 Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents: 8079
diff changeset
175
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
176 if (doplot)
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
177 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
178 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
179 unwind_protect
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
180 for i = 1 : columns (y)
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
181
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
182 if (have_line_spec)
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
183 lc = linespec.color;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
184 if (isempty (lc))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
185 lc = __next_line_color__ ();
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
186 endif
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
187 ls = linespec.linestyle;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
188 if (isempty (ls))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
189 ls = "-";
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
190 endif
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
191 mk = linespec.marker;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
192 if (isempty (mk))
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
193 mk = "none";
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
194 endif
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
195 else
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
196 lc = __next_line_color__ ();
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
197 ls = "-";
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
198 mk = "none";
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
199 endif
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
200
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
201 ## 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
202 hg = hggroup ();
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
203 h = [h; hg];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
204 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
205
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
206 addproperty ("xdata", hg, "data", x(:,i).');
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
207 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
208
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
209 addlistener (hg, "xdata", @update_data);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
210 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
211
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
212 htmp = line (xs(:,i).', ys(:,i).', "color", lc, "linestyle", ls,
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
213 "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
214
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
215 addproperty ("color", hg, "linecolor", get (htmp, "color"));
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
216 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
217 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
218
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
219 addproperty ("marker", hg, "linemarker", get (htmp, "marker"));
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
220 addproperty ("markeredgecolor", hg, "linemarkeredgecolor",
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
221 get (htmp, "markeredgecolor"));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
222 addproperty ("markerfacecolor", hg, "linemarkerfacecolor",
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
223 get (htmp, "markerfacecolor"));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
224 addproperty ("markersize", hg, "linemarkersize",
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
225 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
226
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
227 addlistener (hg, "color", @update_props);
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
228 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
229 addlistener (hg, "linewidth", @update_props);
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
230 addlistener (hg, "marker", @update_props);
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
231 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
232 addlistener (hg, "markerfacecolor", @update_props);
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
233 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
234
17527
76614e624818 Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents: 17462
diff changeset
235 ## 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
236 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
237
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
238 if (! isempty (args))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
239 set (hg, args{:});
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9809
diff changeset
240 endif
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
241 endfor
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
242 unwind_protect_cleanup
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
243 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
244 end_unwind_protect
736
c8f88bd3202b [project @ 1994-09-24 03:28:05 by jwe]
jwe
parents: 245
diff changeset
245 else
7746
95dce69538ec Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents: 7245
diff changeset
246 h = 0;
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
247 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
248
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
249 endfunction
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
250
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
251 function update_props (h, ~)
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
252 set (get (h, "children"),
17572
7bb76a22cde1 maint: Split scripts/plot directory into 4 pieces.
Rik <rik@octave.org>
parents: 17528
diff changeset
253 {"color", "linestyle", "linewidth", "marker", ...
7bb76a22cde1 maint: Split scripts/plot directory into 4 pieces.
Rik <rik@octave.org>
parents: 17528
diff changeset
254 "markeredgecolor", "markerfacecolor", "markersize"},
7bb76a22cde1 maint: Split scripts/plot directory into 4 pieces.
Rik <rik@octave.org>
parents: 17528
diff changeset
255 get (h, {"color", "linestyle", "linewidth", "marker", ...
7bb76a22cde1 maint: Split scripts/plot directory into 4 pieces.
Rik <rik@octave.org>
parents: 17528
diff changeset
256 "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
257 endfunction
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
258
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
259 function update_data (h, ~)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
260
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
261 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
262 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
263
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
264 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
265 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
266 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
267
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
268 nr = length (x);
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
269 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
270 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
271
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
272 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
273 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
274
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
275 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
276 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
277 xs(ridx) = xtmp;
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
278 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
279
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
280 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
281 xs(ridx) = xtmp;
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
282 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
283
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
284 set (get (h, "children"), "xdata", xs, "ydata", ys);
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
285
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7746
diff changeset
286 endfunction
17073
55956e8e21c9 stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16828
diff changeset
287
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
288
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
289 %!demo
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
290 %! clf;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
291 %! 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
292 %! y = rand_1x10_data1;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
293 %! stairs (y);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
294 %! title ('stairs() plot of y-data');
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 %! x = 1:10;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
299 %! 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
300 %! y = rand_1x10_data2;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
301 %! [xs, ys] = stairs (x, y);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
302 %! plot (xs, ys);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21758
diff changeset
303 %! title ("plot() of stairs() generated data");
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
304
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
305 %!demo
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
306 %! clf;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21758
diff changeset
307 %! stairs (1:9, "-o");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21758
diff changeset
308 %! title ("stairs() plot with linespec to modify marker");
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
309
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
310 %!demo
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
311 %! clf;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21758
diff changeset
312 %! stairs (9:-1:1, "marker", "s", "markersize", 10, "markerfacecolor", "m");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21758
diff changeset
313 %! title ("stairs() plot with prop/val pairs to modify appearance");
17433
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 %!demo
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
316 %! clf;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
317 %! N = 11;
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
318 %! x = 0:(N-1);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
319 %! y = rand (1, N);
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
320 %! hs = stairs (x(1), y(1));
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
321 %! axis ([1, N-1 0, 1]);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21758
diff changeset
322 %! title ("stairs plot data modified through handle");
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
323 %! for k = 2:N
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21758
diff changeset
324 %! set (hs, "xdata", x(1:k), "ydata", y(1:k));
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
325 %! drawnow ();
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
326 %! pause (0.2);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21758
diff changeset
327 %! endfor
17433
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 ## Invisible figure used for tests
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
330 %!shared hf, hax
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
331 %! hf = figure ("visible", "off");
28892
3cac3ceb9629 maint: Use coding style with parentheses after function name to distinguish from a variable.
Rik <rik@octave.org>
parents: 28753
diff changeset
332 %! hax = axes ();
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
333
28896
90fea9cc9caa test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents: 28892
diff changeset
334 %!error <Invalid call> stairs ()
17433
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
335 %!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
336 %!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
337 %!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
338 %!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
339 %!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
340 %!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
341 %!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
342
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
343 ## Close figure used for testing
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
344 %!test
2973de961a66 stairs.m: Overhaul function.
Rik <rik@octave.org>
parents: 17301
diff changeset
345 %! close (hf);