comparison 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
comparison
equal deleted inserted replaced
7145:d169c9f4a697 7146:c7e5e638a8d0
1 ## Copyright (C) 2007 Michael Goffioul
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
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
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
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} area (@var{x}, @var{y})
21 ## @deftypefnx {Function File} {} area (@var{x}, @var{y}, @var{lvl})
22 ## @deftypefnx {Function File} {} area (@dots{}, @var{prop}, @var{val}, @dots{})
23 ## @deftypefnx {Function File} {} area (@var{y}, @dots{})
24 ## @deftypefnx {Function File} {} area (@var{h}, @dots{})
25 ## @deftypefnx {Function File} {@var{h} =} area (@dots{})
26 ## Area plot of cummulative sum of the columns of @var{y}. This shows the
27 ## contributions of a value to a sum, and is functionally similar to
28 ## @code{plot (@var{x}, cumsum (@var{y}, 2))}, except that the area under
29 ## the curve is shaded.
30 ##
31 ## If the @var{x} argument is ommitted it is assumed to be given by
32 ## @code{1 : rows (@var{y})}. A value @var{lvl} can be defined that determines
33 ## where the base level of the shading under the curve should be defined.
34 ##
35 ## Additional arguments to the @code{area} function are passed to the
36 ## @code{patch}. The optional return value @var{h} provides a handle to
37 ## the list of patch objects.
38 ## @seealso{plot, patch}
39 ## @end deftypefn
40
41 function [ h ] = area (varargin)
42
43 if (nargin > 0)
44 idx = 1;
45 ax = [];
46 x = y = [];
47 bv = 0;
48 args = {};
49 # check for axes parent
50 if (ishandle (varargin{idx}) &&
51 strcmp (get (varargin{idx}, "type"), "axes"))
52 ax = varargin{idx};
53 idx++;
54 endif
55 # check for (X) or (X,Y) arguments and possible base value
56 if (nargin >= idx && ismatrix (varargin{idx}))
57 y = varargin{idx};
58 idx++;
59 if (nargin >= idx)
60 if (isscalar (varargin{idx}))
61 bv = varargin{idx};
62 idx++;
63 elseif (ismatrix (varargin{idx}))
64 x = y;
65 y = varargin{idx};
66 idx++;
67 if (nargin >= idx && isscalar (varargin{idx}))
68 bv = varargin{idx};
69 idx++;
70 endif
71 endif
72 endif
73 else
74 print_usage ();
75 endif
76 # check for additional args
77 if (nargin >= idx)
78 args = {varargin{idx:end}};
79 endif
80 newplot ();
81 if (isvector (y))
82 y = y(:);
83 endif
84 if (isempty (x))
85 x = repmat ([1:size(y, 1)]', 1, size (y, 2));
86 elseif (isvector (x))
87 x = repmat (x(:), 1, size (y, 2));
88 endif
89
90 if (isempty (ax))
91 tmp = __area__ (gca (), x, y, bv, args{:});
92 else
93 tmp = __area__ (ax, x, y, bv, args{:});
94 endif
95
96 if (nargout > 0)
97 h = tmp;
98 endif
99 else
100 print_usage ();
101 endif
102
103 endfunction