Mercurial > hg > octave-nkf
annotate scripts/plot/draw/stairs.m @ 18415:238aa26b30e3 stable
doc: Re-write documentation for errorbar family of functions.
* errorbar.m: Rewrite docstring.
* loglogerr.m, semilogxerr.m, semilogyerr.m: Update list of forms showing how
function can be called.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 23 Jan 2014 12:49:07 -0800 |
parents | d63878346099 |
children | 446c46af4b42 |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17572
diff
changeset
|
1 ## Copyright (C) 1993-2013 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}) |
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 | 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} |
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 | 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. |
17122
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 (); |
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 | 74 |
75 if (nargout < 2) | |
76 oldfig = []; | |
77 if (! isempty (hax)) | |
78 oldfig = get (0, "currentfigure"); | |
79 endif | |
80 unwind_protect | |
81 hax = newplot (hax); | |
82 [htmp, xxs, yys] = __stairs__ (true, varargin{:}); | |
83 unwind_protect_cleanup | |
84 if (! isempty (oldfig)) | |
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 | 87 end_unwind_protect |
88 if (nargout == 1) | |
89 xs = htmp; | |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
90 endif |
17433 | 91 else |
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 | 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) = []; |
17433 | 102 if (! ismatrix (y) || ndims (y) > 2) |
103 error ("stairs: Y must be a numeric 2-D vector or matrix"); | |
4 | 104 endif |
17433 | 105 if (isvector (y)) |
106 y = y(:); | |
107 endif | |
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) = []; |
17433 | 113 if (! ismatrix (x) || ! ismatrix (y) || ndims (x) > 2 || ndims (y) > 2) |
114 error ("stairs: X and Y must be numeric 2-D vectors or matrices"); | |
115 endif | |
6257 | 116 endif |
117 | |
118 vec_x = isvector (x); | |
119 if (vec_x) | |
120 x = x(:); | |
121 endif | |
122 | |
123 if (isvector (y)) | |
124 y = y(:); | |
17433 | 125 elseif (ismatrix (y) && vec_x) |
126 x = repmat (x, [1, columns(y)]); | |
6257 | 127 endif |
128 | |
17433 | 129 if (! size_equal (x, y)) |
130 error ("stairs: X and Y sizes must match"); | |
4 | 131 endif |
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 | 135 len = 2*nr - 1; |
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 | 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 | 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 | 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 | 146 |
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 | 150 |
8243
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
151 have_line_spec = false; |
17433 | 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 | 157 have_line_spec = true; |
158 varargin(i) = []; | |
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 | 169 |
170 if (have_line_spec) | |
171 lc = linespec.color; | |
172 if (isempty (lc)) | |
173 lc = __next_line_color__ (); | |
174 endif | |
175 ls = linespec.linestyle; | |
176 if (isempty (ls)) | |
177 ls = "-"; | |
178 endif | |
179 mk = linespec.marker; | |
180 if (isempty (mk)) | |
181 mk = "none"; | |
182 endif | |
183 else | |
184 lc = __next_line_color__ (); | |
185 ls = "-"; | |
186 mk = "none"; | |
187 endif | |
188 | |
189 ## Must occur after __next_line_color__ in order to work correctly. | |
10549 | 190 hg = hggroup (); |
191 h = [h; hg]; | |
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 | 194 addproperty ("xdata", hg, "data", x(:,i).'); |
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 | 197 addlistener (hg, "xdata", @update_data); |
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 | 200 htmp = line (xs(:,i).', ys(:,i).', "color", lc, "linestyle", ls, |
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 | 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 | 208 addproperty ("markeredgecolor", hg, "linemarkeredgecolor", |
209 get (htmp, "markeredgecolor")); | |
10549 | 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 | 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 | 215 addlistener (hg, "color", @update_props); |
17433 | 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 | 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 | 226 if (! isempty (args)) |
227 set (hg, args{:}); | |
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 | 233 else |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
234 h = 0; |
4 | 235 endif |
236 | |
237 endfunction | |
7245 | 238 |
17433 | 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 | 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 | 274 |
275 %!demo | |
276 %! clf; | |
277 %! rand_1x10_data1 = [0.073, 0.455, 0.837, 0.124, 0.426, 0.781, 0.004, 0.024, 0.519, 0.698]; | |
278 %! y = rand_1x10_data1; | |
279 %! stairs (y); | |
280 %! title ('stairs() plot of y-data'); | |
281 | |
282 %!demo | |
283 %! clf; | |
284 %! x = 1:10; | |
285 %! rand_1x10_data2 = [0.014, 0.460, 0.622, 0.394, 0.531, 0.378, 0.466, 0.788, 0.342, 0.893]; | |
286 %! y = rand_1x10_data2; | |
287 %! [xs, ys] = stairs (x, y); | |
288 %! plot (xs, ys); | |
289 %! title ('plot() of stairs() generated data'); | |
290 | |
291 %!demo | |
292 %! clf; | |
293 %! stairs (1:9, '-o'); | |
294 %! title ('stairs() plot with linespec to modify marker'); | |
295 | |
296 %!demo | |
297 %! clf; | |
298 %! stairs (9:-1:1, 'marker', 's', 'markersize', 10, 'markerfacecolor', 'm'); | |
299 %! title ('stairs() plot with prop/val pairs to modify appearance'); | |
300 | |
301 %!demo | |
302 %! clf; | |
303 %! N = 11; | |
304 %! x = 0:(N-1); | |
305 %! y = rand (1, N); | |
306 %! hs = stairs (x(1), y(1)); | |
307 %! axis ([1, N-1 0, 1]); | |
308 %! title ('stairs plot data modified through handle'); | |
309 %! for k = 2:N | |
310 %! set (hs, 'xdata', x(1:k), 'ydata', y(1:k)); | |
311 %! drawnow (); | |
312 %! pause (0.2); | |
313 %! end | |
314 | |
315 ## Invisible figure used for tests | |
316 %!shared hf, hax | |
317 %! hf = figure ("visible", "off"); | |
318 %! hax = axes; | |
319 | |
320 %!error stairs () | |
321 %!error <Y must be a numeric 2-D vector> stairs (hax, {1}) | |
322 %!error <Y must be a numeric 2-D vector> stairs (ones (2,2,2)) | |
323 %!error <X and Y must be numeric 2-D vector> stairs ({1}, 1) | |
324 %!error <X and Y must be numeric 2-D vector> stairs (1, {1}) | |
325 %!error <X and Y must be numeric 2-D vector> stairs (ones (2,2,2), 1) | |
326 %!error <X and Y must be numeric 2-D vector> stairs (1, ones (2,2,2)) | |
327 %!error <X and Y sizes must match> stairs (1:2, 1:3) | |
328 | |
329 ## Close figure used for testing | |
330 %!test | |
331 %! close (hf); | |
332 |