Mercurial > hg > octave-lyh
annotate scripts/plot/stairs.m @ 17405:0bf2fc8562c9
doc: Update documentation for file and directory functions.
* libinterp/corefcn/dirfns.cc(Fpwd, Freaddir, Fmkdir, Frmdir, Freadlink, Ffnmatch): Redo docstring.
* libinterp/corefcn/dirfns.cc(Fcd): Redo docstring. Return previous working
directory if nargout > 0.
* libinterp/corefcn/dirfns.cc(Flink, Fsymlink, Frename): Redo docstring.
Re-order return values so that highest numbered value is assigned first to
avoid re-sizing octave_value_list each time.
* libinterp/corefcn/syscalls.cc(Flstat, Fmkfifo, FS_ISREG, FS_ISDIR, FS_ISCHR,
FS_ISBLK, FS_ISFIFO, FS_ISLNK, FS_ISSOCK): Redo docstring.
* scripts/general/isdir.m: Add more xrefs to @seealso.
* scripts/miscellaneous/copyfile.m: Add more xrefs to @seealso.
* scripts/miscellaneous/dir.m: Redo docstring.
* scripts/miscellaneous/ls.m: Add more xrefs to @seealso.m.
* scripts/miscellaneous/movefile.m: Add more xrefs to @seealso.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 09 Sep 2013 14:30:31 -0700 |
parents | 68bcac3c043a |
children | 2973de961a66 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14092
diff
changeset
|
1 ## Copyright (C) 1993-2012 John W. Eaton |
2313 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
245 | 18 |
3368 | 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}) |
17126
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 | 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. |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
32 ## |
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} |
17126
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 | 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 | 45 ## |
3368 | 46 ## @example |
47 ## stairs (x, y); | |
48 ## @end example | |
3426 | 49 ## |
3368 | 50 ## @noindent |
2311 | 51 ## and |
3426 | 52 ## |
3368 | 53 ## @example |
6895 | 54 ## @group |
3368 | 55 ## [xs, ys] = stairs (x, y); |
56 ## plot (xs, ys); | |
6895 | 57 ## @end group |
3368 | 58 ## @end example |
3426 | 59 ## |
3368 | 60 ## @noindent |
2311 | 61 ## are equivalent. |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17073
diff
changeset
|
62 ## @seealso{bar, hist, plot, stem} |
3368 | 63 ## @end deftypefn |
4 | 64 |
2314 | 65 ## Author: jwe |
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 | 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 | 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 (); |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
73 else |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
74 if (nargout > 1) |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
75 [h, xs, ys] = __stairs__ (false, varargin{:}); |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
76 else |
17219
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17130
diff
changeset
|
77 oldfig = []; |
17309
68bcac3c043a
Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
78 if (! isempty (hax)) |
17219
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17130
diff
changeset
|
79 oldfig = get (0, "currentfigure"); |
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17130
diff
changeset
|
80 endif |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
81 unwind_protect |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
82 hax = newplot (hax); |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
83 [htmp, xxs, yys] = __stairs__ (true, varargin{:}); |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
84 unwind_protect_cleanup |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
85 if (! isempty (oldfig)) |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
86 set (0, "currentfigure", oldfig); |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
87 endif |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
88 end_unwind_protect |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
89 if (nargout == 1) |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
90 xs = htmp; |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
91 endif |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
92 endif |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
93 endif |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
94 endfunction |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
95 |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
96 function [h, xs, ys] = __stairs__ (doplot, varargin) |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
97 |
9809
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
98 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
|
99 y = varargin{1}; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
100 varargin(1) = []; |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
101 if (ismatrix (y)) |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
102 if (isvector (y)) |
10549 | 103 y = y(:); |
6257 | 104 endif |
105 x = 1:rows (y); | |
4 | 106 endif |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
107 else |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
108 x = varargin{1}; |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
109 y = varargin{2}; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
110 varargin(1:2) = []; |
6257 | 111 endif |
112 | |
113 if (ndims (x) > 2 || ndims (y) > 2) | |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
114 error ("stairs: X and Y must be 2-D objects"); |
6257 | 115 endif |
116 | |
117 vec_x = isvector (x); | |
118 | |
119 if (vec_x) | |
120 x = x(:); | |
121 endif | |
122 | |
123 if (isvector (y)) | |
124 y = y(:); | |
125 endif | |
126 | |
127 if (ismatrix (y)) | |
128 [nr, nc] = size (y); | |
129 if (vec_x) | |
130 x = repmat (x, [1, nc]); | |
131 else | |
132 [x_nr, x_nc] = size (x); | |
133 if (x_nr != nr || x_nc != nc) | |
10549 | 134 error ("stairs: argument size mismatch"); |
4 | 135 endif |
136 endif | |
137 endif | |
138 | |
6257 | 139 len = 2*nr - 1; |
140 | |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
141 xs = ys = zeros (len, nc); |
6257 | 142 |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
143 xs(1,:) = x(1,:); |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
144 ys(1,:) = y(1,:); |
6257 | 145 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
146 xtmp = x(2:nr,:); |
6257 | 147 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
|
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(1:nr-1,:); |
6257 | 150 |
151 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
|
152 xs(ridx,:) = xtmp; |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
153 ys(ridx,:) = y(2:nr,:); |
6257 | 154 |
8243
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
155 have_line_spec = false; |
8244 | 156 for i = 1 : length (varargin) |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
157 arg = varargin{i}; |
8243
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
158 if ((ischar (arg) || iscell (arg)) && ! have_line_spec) |
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
159 [linespec, valid] = __pltopt__ ("stairs", arg, false); |
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
160 if (valid) |
10549 | 161 have_line_spec = true; |
162 varargin(i) = []; | |
163 break; | |
8243
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
164 endif |
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
165 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
166 endfor |
8243
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
167 |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
168 if (doplot) |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
169 h = []; |
17130
26589abbc78d
Don't pass axis handle unnecessarily from high level to low level plot functions.
Rik <rik@octave.org>
parents:
17126
diff
changeset
|
170 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
|
171 unwind_protect |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
172 for i = 1 : columns (y) |
10549 | 173 hg = hggroup (); |
174 h = [h; hg]; | |
175 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
|
176 |
10549 | 177 addproperty ("xdata", hg, "data", x(:,i).'); |
178 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
|
179 |
10549 | 180 addlistener (hg, "xdata", @update_data); |
181 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
|
182 |
10549 | 183 if (have_line_spec) |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
184 htmp = line (xs(:,i).', ys(:,i).', "color", linespec.color, |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
185 "parent", hg); |
10549 | 186 else |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
187 htmp = line (xs(:,i).', ys(:,i).', "color", __next_line_color__ (), |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
188 "parent", hg); |
10549 | 189 endif |
8075
a028a5960e18
Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents:
8070
diff
changeset
|
190 |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
191 addproperty ("color", hg, "linecolor", get (htmp, "color")); |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
192 addproperty ("linewidth", hg, "linelinewidth", get (htmp, "linewidth")); |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
193 addproperty ("linestyle", hg, "linelinestyle", get (htmp, "linestyle")); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
194 |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
195 addproperty ("marker", hg, "linemarker", get (htmp, "marker")); |
10549 | 196 addproperty ("markerfacecolor", hg, "linemarkerfacecolor", |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
197 get (htmp, "markerfacecolor")); |
10549 | 198 addproperty ("markeredgecolor", hg, "linemarkeredgecolor", |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
199 get (htmp, "markeredgecolor")); |
10549 | 200 addproperty ("markersize", hg, "linemarkersize", |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
201 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
|
202 |
10549 | 203 addlistener (hg, "color", @update_props); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
204 addlistener (hg, "linewidth", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
205 addlistener (hg, "linestyle", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
206 addlistener (hg, "marker", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
207 addlistener (hg, "markerfacecolor", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
208 addlistener (hg, "markeredgecolor", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
209 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
|
210 |
10549 | 211 if (! isempty (args)) |
212 set (hg, args{:}); | |
213 endif | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
214 endfor |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
215 unwind_protect_cleanup |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
216 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
|
217 end_unwind_protect |
736 | 218 else |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
219 h = 0; |
4 | 220 endif |
221 | |
222 endfunction | |
7245 | 223 |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
10736
diff
changeset
|
224 |
7245 | 225 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
226 %! clf; |
7245 | 227 %! x = 1:10; |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
10736
diff
changeset
|
228 %! rand_1x10_data1 = [0.073, 0.455, 0.837, 0.124, 0.426, 0.781, 0.004, 0.024, 0.519, 0.698]; |
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
10736
diff
changeset
|
229 %! y = rand_1x10_data1; |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
230 %! stairs (x, y); |
7245 | 231 |
232 %!demo | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
233 %! clf; |
7245 | 234 %! x = 1:10; |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
10736
diff
changeset
|
235 %! rand_1x10_data2 = [0.014, 0.460, 0.622, 0.394, 0.531, 0.378, 0.466, 0.788, 0.342, 0.893]; |
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
10736
diff
changeset
|
236 %! y = rand_1x10_data2; |
7245 | 237 %! [xs, ys] = stairs (x, y); |
238 %! plot (xs, ys); | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
239 |
9809
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
240 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
241 %! clf; |
9809
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
242 %! stairs (1:9); |
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
243 |
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
244 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
245 %! clf; |
9809
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
246 %! [xs, ys] = stairs (9:-1:1); |
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
247 %! plot (xs, ys); |
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
248 |
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
|
249 %!demo |
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
|
250 %! clf; |
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 %! N = 11; |
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 = 0:(N-1); |
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 = rand (1, N); |
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 %! hs = stairs (x(1), y(1)); |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
255 %! axis ([1, N-1 0, 1]); |
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
|
256 %! for k=2:N |
16828
ddac88d32d6a
Make demos in plot m-files compatible with Matlab for running comparison script.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
257 %! set (hs, 'xdata', x(1:k), 'ydata', y(1:k)); |
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
|
258 %! drawnow (); |
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
|
259 %! pause (0.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
|
260 %! end |
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
|
261 |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
10736
diff
changeset
|
262 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
263 function update_props (h, d) |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
264 set (get (h, "children"), |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
265 "color", get (h, "color"), |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
266 "linewidth", get (h, "linewidth"), |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
267 "linestyle", get (h, "linestyle"), |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
268 "marker", get (h, "marker"), |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
269 "markerfacecolor", get (h, "markerfacecolor"), |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
270 "markeredgecolor", get (h, "markeredgecolor"), |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
271 "markersize", get (h, "markersize")); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
272 endfunction |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
273 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
274 function update_data (h, d) |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
275 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
|
276 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
|
277 |
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
|
278 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
|
279 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
|
280 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
|
281 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
282 nr = length (x); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
283 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
|
284 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
|
285 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
286 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
|
287 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
|
288 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
289 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
|
290 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
|
291 xs(ridx) = xtmp; |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
292 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
|
293 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
294 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
|
295 xs(ridx) = xtmp; |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
296 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
|
297 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
298 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
|
299 endfunction |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
300 |