Mercurial > hg > octave-lyh
comparison scripts/plot/area.m @ 17061:cae21eadc27b
area.m: Update to use new __plt_get_axis_arg__.
* scripts/plot/area.m: Update to use new __plt_get_axis_arg__.
Tweak docstring.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 24 Jul 2013 23:12:46 -0700 |
parents | 02679492b0c6 |
children | eaab03308c0b |
comparison
equal
deleted
inserted
replaced
17060:2d17dbdf6b7d | 17061:cae21eadc27b |
---|---|
20 ## -*- texinfo -*- | 20 ## -*- texinfo -*- |
21 ## @deftypefn {Function File} {} area (@var{y}) | 21 ## @deftypefn {Function File} {} area (@var{y}) |
22 ## @deftypefnx {Function File} {} area (@var{x}, @var{y}) | 22 ## @deftypefnx {Function File} {} area (@var{x}, @var{y}) |
23 ## @deftypefnx {Function File} {} area (@dots{}, @var{lvl}) | 23 ## @deftypefnx {Function File} {} area (@dots{}, @var{lvl}) |
24 ## @deftypefnx {Function File} {} area (@dots{}, @var{prop}, @var{val}, @dots{}) | 24 ## @deftypefnx {Function File} {} area (@dots{}, @var{prop}, @var{val}, @dots{}) |
25 ## @deftypefnx {Function File} {} area (@var{h}, @dots{}) | 25 ## @deftypefnx {Function File} {} area (@var{hax}, @dots{}) |
26 ## @deftypefnx {Function File} {@var{h} =} area (@dots{}) | 26 ## @deftypefnx {Function File} {@var{h} =} area (@dots{}) |
27 ## Area plot of the columns of @var{y}. This shows the | 27 ## Area plot of the columns of @var{y}. This shows the |
28 ## contributions of each column value to the row sum. It is functionally | 28 ## contributions of each column value to the row sum. It is functionally |
29 ## similar to @code{plot (@var{x}, cumsum (@var{y}, 2))}, except that the | 29 ## similar to @code{plot (@var{x}, cumsum (@var{y}, 2))}, except that the |
30 ## area under the curve is shaded. | 30 ## area under the curve is shaded. |
34 ## where the base level of the shading under the curve should be defined. The | 34 ## where the base level of the shading under the curve should be defined. The |
35 ## default level is 0. | 35 ## default level is 0. |
36 ## | 36 ## |
37 ## Additional arguments to the @code{area} function are passed directly to | 37 ## Additional arguments to the @code{area} function are passed directly to |
38 ## @code{patch}. | 38 ## @code{patch}. |
39 ## | |
40 ## If the first argument is an axis handle @var{hax}, then plot into these axes, | |
41 ## rather than the current axis handle returned by @code{gca}. | |
39 ## | 42 ## |
40 ## The optional return value @var{h} is a graphics handle to the hggroup | 43 ## The optional return value @var{h} is a graphics handle to the hggroup |
41 ## object representing the area patch objects. The "BaseValue" property | 44 ## object representing the area patch objects. The "BaseValue" property |
42 ## of the hggroup can be used to adjust the level where shading begins. | 45 ## of the hggroup can be used to adjust the level where shading begins. |
43 ## | 46 ## |
54 ## @seealso{plot, patch} | 57 ## @seealso{plot, patch} |
55 ## @end deftypefn | 58 ## @end deftypefn |
56 | 59 |
57 function h = area (varargin) | 60 function h = area (varargin) |
58 | 61 |
59 [ax, varargin, nargin] = __plt_get_axis_arg__ ("area", varargin{:}); | 62 [hax, varargin, nargin] = __plt_get_axis_arg__ ("area", varargin{:}); |
60 | 63 |
61 if (nargin == 0) | 64 if (nargin == 0) |
62 print_usage (); | 65 print_usage (); |
63 endif | 66 endif |
64 | 67 |
89 endif | 92 endif |
90 ## Check for additional args. | 93 ## Check for additional args. |
91 if (nargin >= idx) | 94 if (nargin >= idx) |
92 args = {varargin{idx:end}}; | 95 args = {varargin{idx:end}}; |
93 endif | 96 endif |
94 newplot (); | |
95 if (isvector (y)) | 97 if (isvector (y)) |
96 y = y(:); | 98 y = y(:); |
97 endif | 99 endif |
98 if (isempty (x)) | 100 if (isempty (x)) |
99 x = repmat ([1:rows(y)]', 1, columns (y)); | 101 x = repmat ([1:rows(y)]', 1, columns (y)); |
100 elseif (isvector (x)) | 102 elseif (isvector (x)) |
101 x = repmat (x(:), 1, columns (y)); | 103 x = repmat (x(:), 1, columns (y)); |
102 endif | 104 endif |
103 | 105 |
104 oldax = gca (); | 106 oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); |
105 unwind_protect | 107 unwind_protect |
106 axes (ax); | 108 hax = newplot (hax); |
107 tmp = __area__ (ax, x, y, bv, args{:}); | 109 htmp = __area__ (hax, x, y, bv, args{:}); |
108 unwind_protect_cleanup | 110 unwind_protect_cleanup |
109 axes (oldax); | 111 if (! isempty (oldfig)) |
112 set (0, "currentfigure", oldfig); | |
113 endif | |
110 end_unwind_protect | 114 end_unwind_protect |
111 | 115 |
112 if (nargout > 0) | 116 if (nargout > 0) |
113 h = tmp; | 117 h = htmp; |
114 endif | 118 endif |
115 | 119 |
116 endfunction | 120 endfunction |
117 | 121 |
118 function retval = __area__ (ax, x, y, bv, varargin) | 122 function retval = __area__ (ax, x, y, bv, varargin) |