1## Copyright (C) 2007, 2008, 2009 Michael Goffioul
3## This file is part of Octave.
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.
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.
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/>.
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 cumulative 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.
31## If the @var{x} argument is omitted 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.
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## area series object representing the patches of the areas.
38## @seealso{plot, patch}
41function h = area (varargin)
43 [ax, varargin, nargin] = __plt_get_axis_arg__ ("area", varargin{:});
50 ## Check for (X) or (X,Y) arguments and possible base value.
51 if (nargin >= idx && ismatrix (varargin{idx}))
55 if (isscalar (varargin{idx}))
58 elseif (ismatrix (varargin{idx}))
62 if (nargin >= idx && isscalar (varargin{idx}))
71 ## Check for additional args.
73 args = {varargin{idx:end}};
80 x = repmat ([1:size(y, 1)]', 1, size (y, 2));
82 x = repmat (x(:), 1, size (y, 2));
88 tmp = __area__ (ax, x, y, bv, args{:});
89 unwind_protect_cleanup