changelog shortlog tags changeset files revisions annotate raw

scripts/plot/area.m

changeset 9846: 1d90fc211872
parent:dbd0c77e575e
author: John W. Eaton <jwe@octave.org>
date: Sat Nov 21 21:44:51 2009 -0500 (21 hours ago)
permissions: -rw-r--r--
description: configure.ac: report freetype, fontconfig, and fltk cflags and libs info
1## Copyright (C) 2007, 2008, 2009 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 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.
30##
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.
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## area series object representing the patches of the areas.
38## @seealso{plot, patch}
39## @end deftypefn
40
41function h = area (varargin)
42
43 [ax, varargin, nargin] = __plt_get_axis_arg__ ("area", varargin{:});
44
45 if (nargin > 0)
46 idx = 1;
47 x = y = [];
48 bv = 0;
49 args = {};
50 ## Check for (X) or (X,Y) arguments and possible base value.
51 if (nargin >= idx && ismatrix (varargin{idx}))
52 y = varargin{idx};
53 idx++;
54 if (nargin >= idx)
55 if (isscalar (varargin{idx}))
56 bv = varargin{idx};
57 idx++;
58 elseif (ismatrix (varargin{idx}))
59 x = y;
60 y = varargin{idx};
61 idx++;
62 if (nargin >= idx && isscalar (varargin{idx}))
63 bv = varargin{idx};
64 idx++;
65 endif
66 endif
67 endif
68 else
69 print_usage ();
70 endif
71 ## Check for additional args.
72 if (nargin >= idx)
73 args = {varargin{idx:end}};
74 endif
75 newplot ();
76 if (isvector (y))
77 y = y(:);
78 endif
79 if (isempty (x))
80 x = repmat ([1:size(y, 1)]', 1, size (y, 2));
81 elseif (isvector (x))
82 x = repmat (x(:), 1, size (y, 2));
83 endif
84
85 oldax = gca ();
86 unwind_protect
87 axes (ax);
88 tmp = __area__ (ax, x, y, bv, args{:});
89 unwind_protect_cleanup
90 axes (oldax);
91 end_unwind_protect
92
93 if (nargout > 0)
94 h = tmp;
95 endif
96 else
97 print_usage ();
98 endif
99
100endfunction