annotate scripts/plot/area.m @ 7146:c7e5e638a8d0

[project @ 2007-11-09 17:49:44 by jwe]
author jwe
date Fri, 09 Nov 2007 17:51:42 +0000
parents
children fdb3840cec66
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7146
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 2007 Michael Goffioul
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
2 ##
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
4 ##
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
8 ## your option) any later version.
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
9 ##
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
14 ##
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
18
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
20 ## @deftypefn {Function File} {} area (@var{x}, @var{y})
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
21 ## @deftypefnx {Function File} {} area (@var{x}, @var{y}, @var{lvl})
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
22 ## @deftypefnx {Function File} {} area (@dots{}, @var{prop}, @var{val}, @dots{})
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
23 ## @deftypefnx {Function File} {} area (@var{y}, @dots{})
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
24 ## @deftypefnx {Function File} {} area (@var{h}, @dots{})
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
25 ## @deftypefnx {Function File} {@var{h} =} area (@dots{})
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
26 ## Area plot of cummulative sum of the columns of @var{y}. This shows the
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
27 ## contributions of a value to a sum, and is functionally similar to
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
28 ## @code{plot (@var{x}, cumsum (@var{y}, 2))}, except that the area under
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
29 ## the curve is shaded.
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
30 ##
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
31 ## If the @var{x} argument is ommitted it is assumed to be given by
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
32 ## @code{1 : rows (@var{y})}. A value @var{lvl} can be defined that determines
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
33 ## where the base level of the shading under the curve should be defined.
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
34 ##
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
35 ## Additional arguments to the @code{area} function are passed to the
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
36 ## @code{patch}. The optional return value @var{h} provides a handle to
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
37 ## the list of patch objects.
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
38 ## @seealso{plot, patch}
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
39 ## @end deftypefn
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
40
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
41 function [ h ] = area (varargin)
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
42
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
43 if (nargin > 0)
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
44 idx = 1;
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
45 ax = [];
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
46 x = y = [];
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
47 bv = 0;
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
48 args = {};
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
49 # check for axes parent
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
50 if (ishandle (varargin{idx}) &&
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
51 strcmp (get (varargin{idx}, "type"), "axes"))
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
52 ax = varargin{idx};
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
53 idx++;
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
54 endif
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
55 # check for (X) or (X,Y) arguments and possible base value
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
56 if (nargin >= idx && ismatrix (varargin{idx}))
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
57 y = varargin{idx};
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
58 idx++;
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
59 if (nargin >= idx)
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
60 if (isscalar (varargin{idx}))
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
61 bv = varargin{idx};
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
62 idx++;
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
63 elseif (ismatrix (varargin{idx}))
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
64 x = y;
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
65 y = varargin{idx};
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
66 idx++;
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
67 if (nargin >= idx && isscalar (varargin{idx}))
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
68 bv = varargin{idx};
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
69 idx++;
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
70 endif
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
71 endif
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
72 endif
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
73 else
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
74 print_usage ();
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
75 endif
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
76 # check for additional args
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
77 if (nargin >= idx)
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
78 args = {varargin{idx:end}};
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
79 endif
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
80 newplot ();
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
81 if (isvector (y))
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
82 y = y(:);
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
83 endif
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
84 if (isempty (x))
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
85 x = repmat ([1:size(y, 1)]', 1, size (y, 2));
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
86 elseif (isvector (x))
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
87 x = repmat (x(:), 1, size (y, 2));
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
88 endif
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
89
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
90 if (isempty (ax))
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
91 tmp = __area__ (gca (), x, y, bv, args{:});
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
92 else
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
93 tmp = __area__ (ax, x, y, bv, args{:});
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
94 endif
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
95
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
96 if (nargout > 0)
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
97 h = tmp;
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
98 endif
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
99 else
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
100 print_usage ();
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
101 endif
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
102
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents:
diff changeset
103 endfunction