Mercurial > hg > octave-nkf
annotate scripts/plot/stairs.m @ 17122:eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Emphasize clarity, use common "voice", and increase density of seealso links.
* doc/interpreter/plot.txi: Add @findex entries that were in xlim.m
* scripts/miscellaneous/getappdata.m scripts/miscellaneous/setappdata.m,
scripts/plot/allchild.m, scripts/plot/ancestor.m, scripts/plot/area.m,
scripts/plot/axes.m, scripts/plot/axis.m, scripts/plot/bar.m,
scripts/plot/barh.m, scripts/plot/box.m, scripts/plot/caxis.m,
scripts/plot/cla.m, scripts/plot/clabel.m, scripts/plot/clf.m,
scripts/plot/close.m, scripts/plot/closereq.m, scripts/plot/colorbar.m,
scripts/plot/comet.m, scripts/plot/comet3.m, scripts/plot/compass.m,
scripts/plot/contour.m, scripts/plot/contour3.m, scripts/plot/contourc.m,
scripts/plot/contourf.m, scripts/plot/copyobj.m, scripts/plot/cylinder.m,
scripts/plot/daspect.m, scripts/plot/diffuse.m, scripts/plot/ellipsoid.m,
scripts/plot/errorbar.m, scripts/plot/ezcontour.m, scripts/plot/ezcontourf.m,
scripts/plot/ezmesh.m, scripts/plot/ezmeshc.m, scripts/plot/ezplot.m,
scripts/plot/ezplot3.m, scripts/plot/ezpolar.m, scripts/plot/ezsurf.m,
scripts/plot/ezsurfc.m, scripts/plot/feather.m, scripts/plot/figure.m,
scripts/plot/fill.m, scripts/plot/findall.m, scripts/plot/findobj.m,
scripts/plot/fplot.m, scripts/plot/gca.m, scripts/plot/gcbf.m,
scripts/plot/gcbo.m, scripts/plot/gcf.m, scripts/plot/gco.m,
scripts/plot/ginput.m, scripts/plot/graphics_toolkit.m, scripts/plot/grid.m,
scripts/plot/gtext.m, scripts/plot/guidata.m, scripts/plot/guihandles.m,
scripts/plot/hdl2struct.m, scripts/plot/hggroup.m, scripts/plot/hidden.m,
scripts/plot/hist.m, scripts/plot/hold.m, scripts/plot/ishghandle.m,
scripts/plot/ishold.m, scripts/plot/isocolors.m, scripts/plot/isprop.m,
scripts/plot/legend.m, scripts/plot/line.m, scripts/plot/linkprop.m,
scripts/plot/loglog.m, scripts/plot/loglogerr.m, scripts/plot/mesh.m,
scripts/plot/meshc.m, scripts/plot/meshgrid.m, scripts/plot/meshz.m,
scripts/plot/newplot.m, scripts/plot/orient.m, scripts/plot/pareto.m,
scripts/plot/patch.m, scripts/plot/pcolor.m, scripts/plot/peaks.m,
scripts/plot/pie.m, scripts/plot/pie3.m, scripts/plot/plot.m,
scripts/plot/plot3.m, scripts/plot/plotmatrix.m, scripts/plot/plotyy.m,
scripts/plot/polar.m, scripts/plot/print.m, scripts/plot/quiver.m,
scripts/plot/quiver3.m, scripts/plot/rectangle.m, scripts/plot/refresh.m,
scripts/plot/refreshdata.m, scripts/plot/ribbon.m, scripts/plot/rose.m,
scripts/plot/saveas.m, scripts/plot/scatter.m, scripts/plot/scatter3.m,
scripts/plot/semilogx.m, scripts/plot/semilogxerr.m, scripts/plot/semilogy.m,
scripts/plot/semilogyerr.m, scripts/plot/shading.m, scripts/plot/shg.m,
scripts/plot/shrinkfaces.m, scripts/plot/slice.m, scripts/plot/specular.m,
scripts/plot/sphere.m, scripts/plot/stairs.m, scripts/plot/stem.m,
scripts/plot/stem3.m, scripts/plot/struct2hdl.m, scripts/plot/subplot.m,
scripts/plot/surf.m, scripts/plot/surface.m, scripts/plot/surfc.m,
scripts/plot/surfl.m, scripts/plot/tetramesh.m, scripts/plot/text.m,
scripts/plot/title.m, scripts/plot/trimesh.m, scripts/plot/triplot.m,
scripts/plot/trisurf.m, scripts/plot/view.m, scripts/plot/waitbar.m,
scripts/plot/waitforbuttonpress.m, scripts/plot/waterfall.m,
scripts/plot/whitebg.m, scripts/plot/xlabel.m, scripts/plot/xlim.m,
scripts/plot/ylabel.m, scripts/plot/ylim.m, scripts/plot/zlabel.m,
scripts/plot/zlim.m: Rewrite docstrings for most plot functions.
Emphasize clarity, use common "voice", and increase density of seealso links.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 31 Jul 2013 13:53:30 -0700 |
parents | 55956e8e21c9 |
children | 26589abbc78d |
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}) |
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 (); |
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 |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
77 oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
78 unwind_protect |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
79 hax = newplot (hax); |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
80 [htmp, xxs, yys] = __stairs__ (true, varargin{:}); |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
81 unwind_protect_cleanup |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
82 if (! isempty (oldfig)) |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
83 set (0, "currentfigure", oldfig); |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
84 endif |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
85 end_unwind_protect |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
86 if (nargout == 1) |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
87 xs = htmp; |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
88 endif |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
89 endif |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
90 endif |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
91 endfunction |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
92 |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
93 function [h, xs, ys] = __stairs__ (doplot, varargin) |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
94 |
9809
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
95 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
|
96 y = varargin{1}; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
97 varargin(1) = []; |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
98 if (ismatrix (y)) |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
99 if (isvector (y)) |
10549 | 100 y = y(:); |
6257 | 101 endif |
102 x = 1:rows (y); | |
4 | 103 endif |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
104 else |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
105 x = varargin{1}; |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
106 y = varargin{2}; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
107 varargin(1:2) = []; |
6257 | 108 endif |
109 | |
110 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
|
111 error ("stairs: X and Y must be 2-D objects"); |
6257 | 112 endif |
113 | |
114 vec_x = isvector (x); | |
115 | |
116 if (vec_x) | |
117 x = x(:); | |
118 endif | |
119 | |
120 if (isvector (y)) | |
121 y = y(:); | |
122 endif | |
123 | |
124 if (ismatrix (y)) | |
125 [nr, nc] = size (y); | |
126 if (vec_x) | |
127 x = repmat (x, [1, nc]); | |
128 else | |
129 [x_nr, x_nc] = size (x); | |
130 if (x_nr != nr || x_nc != nc) | |
10549 | 131 error ("stairs: argument size mismatch"); |
4 | 132 endif |
133 endif | |
134 endif | |
135 | |
6257 | 136 len = 2*nr - 1; |
137 | |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
138 xs = ys = zeros (len, nc); |
6257 | 139 |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
140 xs(1,:) = x(1,:); |
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
141 ys(1,:) = y(1,:); |
6257 | 142 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
143 xtmp = x(2:nr,:); |
6257 | 144 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
|
145 xs(ridx,:) = xtmp; |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
146 ys(ridx,:) = y(1:nr-1,:); |
6257 | 147 |
148 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
|
149 xs(ridx,:) = xtmp; |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
150 ys(ridx,:) = y(2:nr,:); |
6257 | 151 |
8243
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
152 have_line_spec = false; |
8244 | 153 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
|
154 arg = varargin{i}; |
8243
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
155 if ((ischar (arg) || iscell (arg)) && ! have_line_spec) |
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
156 [linespec, valid] = __pltopt__ ("stairs", arg, false); |
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
157 if (valid) |
10549 | 158 have_line_spec = true; |
159 varargin(i) = []; | |
160 break; | |
8243
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
161 endif |
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
162 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
163 endfor |
8243
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8079
diff
changeset
|
164 |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
165 if (doplot) |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
166 h = []; |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
167 unwind_protect |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
168 hold_state = get (gca (), "nextplot"); |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
169 for i = 1 : columns (y) |
10549 | 170 hg = hggroup (); |
171 h = [h; hg]; | |
172 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
|
173 |
10549 | 174 addproperty ("xdata", hg, "data", x(:,i).'); |
175 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
|
176 |
10549 | 177 addlistener (hg, "xdata", @update_data); |
178 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
|
179 |
10549 | 180 if (have_line_spec) |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
181 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
|
182 "parent", hg); |
10549 | 183 else |
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", __next_line_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 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
|
187 |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
188 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
|
189 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
|
190 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
|
191 |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
192 addproperty ("marker", hg, "linemarker", get (htmp, "marker")); |
10549 | 193 addproperty ("markerfacecolor", hg, "linemarkerfacecolor", |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
194 get (htmp, "markerfacecolor")); |
10549 | 195 addproperty ("markeredgecolor", hg, "linemarkeredgecolor", |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
196 get (htmp, "markeredgecolor")); |
10549 | 197 addproperty ("markersize", hg, "linemarkersize", |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
198 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
|
199 |
10549 | 200 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
|
201 addlistener (hg, "linewidth", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
202 addlistener (hg, "linestyle", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
203 addlistener (hg, "marker", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
204 addlistener (hg, "markerfacecolor", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
205 addlistener (hg, "markeredgecolor", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
206 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
|
207 |
10549 | 208 if (! isempty (args)) |
209 set (hg, args{:}); | |
210 endif | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
211 endfor |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
212 unwind_protect_cleanup |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
213 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
|
214 end_unwind_protect |
736 | 215 else |
7746
95dce69538ec
Allow additional options to stairs plots
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
216 h = 0; |
4 | 217 endif |
218 | |
219 endfunction | |
7245 | 220 |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
10736
diff
changeset
|
221 |
7245 | 222 %!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
|
223 %! clf; |
7245 | 224 %! x = 1:10; |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
10736
diff
changeset
|
225 %! 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
|
226 %! 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
|
227 %! stairs (x, y); |
7245 | 228 |
229 %!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
|
230 %! clf; |
7245 | 231 %! x = 1:10; |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
10736
diff
changeset
|
232 %! 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
|
233 %! y = rand_1x10_data2; |
7245 | 234 %! [xs, ys] = stairs (x, y); |
235 %! 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
|
236 |
9809
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
237 %!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
|
238 %! clf; |
9809
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
239 %! stairs (1:9); |
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
240 |
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
241 %!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
|
242 %! clf; |
9809
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
243 %! [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
|
244 %! plot (xs, ys); |
965487e00282
stairs.m (__stairs__): correct nargin check; new demos
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
245 |
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
|
246 %!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
|
247 %! 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
|
248 %! 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
|
249 %! 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
|
250 %! 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
|
251 %! 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
|
252 %! 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
|
253 %! 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
|
254 %! 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
|
255 %! 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
|
256 %! 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
|
257 %! 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
|
258 |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
10736
diff
changeset
|
259 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
260 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
|
261 set (get (h, "children"), |
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
262 "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
|
263 "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
|
264 "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
|
265 "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
|
266 "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
|
267 "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
|
268 "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
|
269 endfunction |
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 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
|
272 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
|
273 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
|
274 |
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
|
275 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
|
276 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
|
277 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
|
278 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
279 nr = length (x); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
280 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
|
281 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
|
282 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
283 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
|
284 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
|
285 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
286 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
|
287 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
|
288 xs(ridx) = xtmp; |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
289 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
|
290 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
291 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
|
292 xs(ridx) = xtmp; |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
293 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
|
294 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7746
diff
changeset
|
295 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
|
296 endfunction |
17073
55956e8e21c9
stairs.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16828
diff
changeset
|
297 |