Mercurial > hg > octave-nkf
annotate scripts/plot/area.m @ 16491:b10a23fe80bb
doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility.
* scripts/audio/wavread.m, scripts/miscellaneous/getappdata.m,
scripts/miscellaneous/license.m, scripts/miscellaneous/ver.m,
scripts/plot/daspect.m, scripts/plot/graphics_toolkit.m,
scripts/plot/pbaspect.m, scripts/polynomial/splinefit.m, scripts/set/union.m,
scripts/signal/freqz.m: Improve docstring wording.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 10 Apr 2013 22:43:30 -0700 |
parents | ab1c6e6d1be6 |
children | 12005245b645 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14001
diff
changeset
|
1 ## Copyright (C) 2007-2012 Michael Goffioul |
11523 | 2 ## Copyright (C) 2007-2009 David Bateman |
7146 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
8 ## the Free Software Foundation; either version 3 of the License, or (at | |
9 ## your option) any later version. | |
10 ## | |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
17 ## along with Octave; see the file COPYING. If not, see | |
18 ## <http://www.gnu.org/licenses/>. | |
19 | |
20 ## -*- texinfo -*- | |
15566
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
21 ## @deftypefn {Function File} {} area (@var{y}) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
22 ## @deftypefnx {Function File} {} area (@var{x}, @var{y}) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
23 ## @deftypefnx {Function File} {} area (@dots{}, @var{lvl}) |
7146 | 24 ## @deftypefnx {Function File} {} area (@dots{}, @var{prop}, @var{val}, @dots{}) |
25 ## @deftypefnx {Function File} {} area (@var{h}, @dots{}) | |
26 ## @deftypefnx {Function File} {@var{h} =} area (@dots{}) | |
15566
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
27 ## Area plot of the columns of @var{y}. This shows the |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
28 ## contributions of each column value to the row sum. It is functionally similar to |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
29 ## @code{plot (@var{x}, cumsum (@var{y}, 2))}, except that the area under |
7146 | 30 ## the curve is shaded. |
31 ## | |
15566
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
32 ## If the @var{x} argument is omitted it defaults to |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
33 ## @code{1 : rows (@var{y})}. A value @var{lvl} can be defined that determines |
15566
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
34 ## where the base level of the shading under the curve should be defined. The |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
35 ## default level is 0. |
7146 | 36 ## |
15566
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
37 ## Additional arguments to the @code{area} function are passed directly to |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
38 ## @code{patch}. |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
39 ## |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
40 ## The optional return value @var{h} is a graphics handle to the hggroup |
15566
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
41 ## object representing the area patch objects. The "BaseValue" property |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
42 ## of the hggroup can be used to adjust the level where shading begins. |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
43 ## |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
44 ## Example: Verify identity sin^2 + cos^2 = 1 |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
45 ## |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
46 ## @example |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
47 ## t = linspace (0, 2*pi, 100)'; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
48 ## y = [sin(t).^2, cos(t).^2)]; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
49 ## area (t, y); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
50 ## legend ('sin^2', 'cos^2', 'location', 'NorthEastOutside'); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
51 ## @end example |
7146 | 52 ## @seealso{plot, patch} |
53 ## @end deftypefn | |
54 | |
7147 | 55 function h = area (varargin) |
7146 | 56 |
7215 | 57 [ax, varargin, nargin] = __plt_get_axis_arg__ ("area", varargin{:}); |
58 | |
15566
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
59 if (nargin == 0) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
60 print_usage (); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
61 endif |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
62 |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
63 idx = 1; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
64 x = y = []; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
65 bv = 0; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
66 args = {}; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
67 ## Check for (X) or (X,Y) arguments and possible base value. |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
68 if (nargin >= idx && ismatrix (varargin{idx})) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
69 y = varargin{idx}; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
70 idx++; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
71 if (nargin >= idx) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
72 if (isscalar (varargin{idx})) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
73 bv = varargin{idx}; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
74 idx++; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
75 elseif (ismatrix (varargin{idx})) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
76 x = y; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
77 y = varargin{idx}; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
78 idx++; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
79 if (nargin >= idx && isscalar (varargin{idx})) |
7146 | 80 bv = varargin{idx}; |
81 idx++; | |
82 endif | |
83 endif | |
84 endif | |
85 else | |
86 print_usage (); | |
87 endif | |
15566
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
88 ## Check for additional args. |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
89 if (nargin >= idx) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
90 args = {varargin{idx:end}}; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
91 endif |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
92 newplot (); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
93 if (isvector (y)) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
94 y = y(:); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
95 endif |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
96 if (isempty (x)) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
97 x = repmat ([1:rows(y)]', 1, columns (y)); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
98 elseif (isvector (x)) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
99 x = repmat (x(:), 1, columns (y)); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
100 endif |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
101 |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
102 oldax = gca (); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
103 unwind_protect |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
104 axes (ax); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
105 tmp = __area__ (ax, x, y, bv, args{:}); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
106 unwind_protect_cleanup |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
107 axes (oldax); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
108 end_unwind_protect |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
109 |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
110 if (nargout > 0) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
111 h = tmp; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
112 endif |
7146 | 113 |
114 endfunction | |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
115 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
116 function retval = __area__ (ax, x, y, bv, varargin) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
117 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
118 y0 = bv * ones (1, rows (y)); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
119 y0 = zeros (1, rows (y)); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
120 retval = []; |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
121 for i = 1: columns (y); |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
122 hg = hggroup (); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
123 retval = [retval; hg]; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
124 args = __add_datasource__ ("area", hg, {"x", "y"}, varargin{:}); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
125 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
126 x1 = x(:, 1).'; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
127 y1 = y (:, i).'; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
128 addproperty ("xdata", hg, "data", x1); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
129 addproperty ("ydata", hg, "data", y1); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
130 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
131 addlistener (hg, "xdata", @update_data); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
132 addlistener (hg, "ydata", @update_data); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
133 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
134 if (i == 1) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
135 h = patch (ax, [x1(1), x1, fliplr(x1)], [bv, y1, bv*ones(1, length(y1))], |
10549 | 136 __next_line_color__ (), "parent", hg); |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
137 else |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
138 y1 = y0 + y1; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
139 h = patch (ax, [x1(1), x1, fliplr(x1)], [y0(1), y1, fliplr(y0)], |
10549 | 140 __next_line_color__ (), "parent", hg); |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
141 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
142 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
143 y0 = y1; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
144 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
145 addproperty ("basevalue", hg, "data", bv); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
146 addlistener (hg, "basevalue", @move_baseline); |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
147 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
148 addproperty ("edgecolor", hg, "patchedgecolor", get (h, "edgecolor")); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
149 addproperty ("linewidth", hg, "patchlinewidth", get (h, "linewidth")); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
150 addproperty ("linestyle", hg, "patchlinestyle", get (h, "linestyle")); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
151 addproperty ("facecolor", hg, "patchfacecolor", get (h, "facecolor")); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
152 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
153 addlistener (hg, "edgecolor", @update_props); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
154 addlistener (hg, "linewidth", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
155 addlistener (hg, "linestyle", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
156 addlistener (hg, "facecolor", @update_props); |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
157 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
158 addproperty ("areagroup", hg, "data"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
159 set (retval, "areagroup", retval); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
160 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
161 if (! isempty (args)) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
162 set (hg, args{:}); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
163 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
164 endfor |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
165 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
166 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
167 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
168 function update_props (h, d) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
169 kids = get (h, "children"); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
170 set (kids, "edgecolor", get (h, "edgecolor"), |
15566
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
171 "linewidth", get (h, "linewidth"), |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
172 "linestyle", get (h, "linestyle"), |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
173 "facecolor", get (h, "facecolor")); |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
174 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
175 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
176 function move_baseline (h, d) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
177 persistent recursion = false; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
178 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
179 ## Don't allow recursion |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
180 if (! recursion) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
181 unwind_protect |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
182 recursion = true; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
183 hlist = get (h, "areagroup"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
184 b0 = get (h, "basevalue"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
185 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
186 for hh = hlist(:)' |
10549 | 187 if (hh != h) |
188 b1 = get (hh, "basevalue"); | |
189 if (b1 != b0) | |
190 set (hh, "basevalue", b0); | |
191 endif | |
192 endif | |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
193 endfor |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
194 update_data (h, d); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
195 unwind_protect_cleanup |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
196 recursion = false; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
197 end_unwind_protect |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
198 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
199 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
200 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
201 function update_data (h, d) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
202 hlist = get (h, "areagroup"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
203 bv = get (h, "basevalue"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
204 for i = 1 : length (hlist) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
205 hh = hlist(i); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
206 x1 = get (hh, "xdata")(:); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
207 y1 = get (hh, "ydata")(:); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
208 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
209 set (get (hh, "children"), "xdata", [x1(1); x1; flipud(x1)]); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
210 if (i == 1) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
211 set (get (hh, "children"), "ydata", [bv; y1; bv*ones(length(y1), 1)]); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
212 else |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
213 y1 = y0 + y1; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
214 set (get (hh, "children"), "ydata", [y0(1); y1; flipud(y0)]); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
215 endif |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
216 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
217 y0 = y1; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
218 endfor |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
219 endfunction |
15566
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
220 |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
221 |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
222 %!demo |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
223 %! # Verify identity sin^2 + cos^2 = 1 |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
224 %! clf; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
225 %! t = linspace (0, 2*pi, 100)'; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
226 %! y = [sin(t).^2, cos(t).^2]; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
227 %! area (t, y); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
228 %! legend ('sin^2', 'cos^2', 'location', 'NorthEastOutside'); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
229 |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
230 %!demo |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
231 %! # Show effects of setting BaseValue |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
232 %! clf; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
233 %! x = [-2:0.1:2]'; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
234 %! y = x.^2 - 1; |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
235 %! subplot (1, 2, 1) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
236 %! area (x, y); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
237 %! title ({'Parabola y = x^2 -1';'BaseValue = 0'}); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
238 %! subplot (1, 2, 2) |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
239 %! h = area (x, y); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
240 %! set (h, 'basevalue', -1); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
241 %! title ({'Parabola y = x^2 -1';'BaseValue = -1'}); |
ab1c6e6d1be6
area.m: Add demos and redo docstring.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
242 |