Mercurial > hg > octave-nkf
comparison scripts/plot/pie.m @ 17064:84e000930ca5
pie.m, pie3.m: Update to use new __plt_get_axis_arg__.
* scripts/plot/pie.m, scripts/plot/pie3.m: Update to use new
__plt_get_axis_arg__. Rewrite docstring to explain "missing" slices.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 24 Jul 2013 23:12:46 -0700 |
parents | 64e7bb01fce2 |
children | eaab03308c0b |
comparison
equal
deleted
inserted
replaced
17063:f17d9a574645 | 17064:84e000930ca5 |
---|---|
16 ## along with Octave; see the file COPYING. If not, see | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | 17 ## <http://www.gnu.org/licenses/>. |
18 | 18 |
19 ## -*- texinfo -*- | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} pie (@var{x}) | 20 ## @deftypefn {Function File} {} pie (@var{x}) |
21 ## @deftypefnx {Function File} {} pie (@var{x}, @var{explode}) | 21 ## @deftypefnx {Function File} {} pie (@dots{}, @var{explode}) |
22 ## @deftypefnx {Function File} {} pie (@dots{}, @var{labels}) | 22 ## @deftypefnx {Function File} {} pie (@dots{}, @var{labels}) |
23 ## @deftypefnx {Function File} {} pie (@var{h}, @dots{}); | 23 ## @deftypefnx {Function File} {} pie (@var{hax}, @dots{}); |
24 ## @deftypefnx {Function File} {@var{h} =} pie (@dots{}); | 24 ## @deftypefnx {Function File} {@var{h} =} pie (@dots{}); |
25 ## Plot a 2-D pie chart. | 25 ## Plot a 2-D pie chart. |
26 ## | 26 ## |
27 ## When called with a single vector argument, produce a pie chart of the | 27 ## When called with a single vector argument, produce a pie chart of the |
28 ## elements in @var{x}. The size of the ith slice is the percentage that the | 28 ## elements in @var{x}. The size of the ith slice is the percentage that the |
29 ## element @var{x}i represents of the total sum of @var{x}. | 29 ## element @var{x}i represents of the total sum of @var{x}: |
30 ## @code{pct = @var{x}(i) / sum (@var{x})}. | |
30 ## | 31 ## |
31 ## The variable @var{explode} is a vector of the same length as @var{x} that, | 32 ## The optional input @var{explode} is a vector of the same length as @var{x} |
32 ## if non-zero, "explodes" the slice from the pie chart. | 33 ## that, if non-zero, "explodes" the slice from the pie chart. |
33 ## | 34 ## |
34 ## The optional input @var{labels} is a cell array of strings of the same | 35 ## The optional input @var{labels} is a cell array of strings of the same |
35 ## length as @var{x} specifying the label for each slice. | 36 ## length as @var{x} specifying the label for each slice. |
37 ## | |
38 ## If the first argument @var{hax} is an axis handle, then plot into these axes, | |
39 ## rather than the current axis handle returned by @code{gca}. | |
36 ## | 40 ## |
37 ## The optional return value @var{h} is a list of handles to the patch | 41 ## The optional return value @var{h} is a list of handles to the patch |
38 ## and text objects generating the plot. | 42 ## and text objects generating the plot. |
39 ## | 43 ## |
40 ## @seealso{pie3, bar, stem} | 44 ## Note: If @code{sum (@var{x}) @leq{} 1} then the elements of @var{x} are |
45 ## interpreted as percentages directly and are not normalized by @code{sum (x)}. | |
46 ## Furthermore, if the sum is less than 1 then there will be a missing slice | |
47 ## in the pie plot to represent the missing, unspecified percentage. | |
48 ## | |
49 ## @seealso{pie3, bar, hist, rose} | |
41 ## @end deftypefn | 50 ## @end deftypefn |
42 | 51 |
43 ## Very roughly based on pie.m from octave-forge whose author was | 52 ## Very roughly based on pie.m from octave-forge whose author was |
44 ## Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de> | 53 ## Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de> |
45 | 54 |
46 function retval = pie (varargin) | 55 function h = pie (varargin) |
47 | 56 |
48 [h, varargin] = __plt_get_axis_arg__ ("pie", varargin{:}); | 57 [hax, varargin, nargin] = __plt_get_axis_arg__ ("pie", varargin{:}); |
49 | 58 |
50 if (nargin < 1) | 59 if (nargin < 1) |
51 print_usage (); | 60 print_usage (); |
52 else | |
53 oldh = gca (); | |
54 unwind_protect | |
55 axes (h); | |
56 newplot (); | |
57 tmp = __pie__ ("pie", h, varargin{:}); | |
58 unwind_protect_cleanup | |
59 axes (oldh); | |
60 end_unwind_protect | |
61 endif | 61 endif |
62 | 62 |
63 oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); | |
64 unwind_protect | |
65 hax = newplot (hax); | |
66 htmp = __pie__ ("pie", hax, varargin{:}); | |
67 unwind_protect_cleanup | |
68 if (! isempty (oldfig)) | |
69 set (0, "currentfigure", oldfig); | |
70 endif | |
71 end_unwind_protect | |
72 | |
63 if (nargout > 0) | 73 if (nargout > 0) |
64 retval = tmp; | 74 h = htmp; |
65 endif | 75 endif |
66 | 76 |
67 endfunction | 77 endfunction |
68 | 78 |
69 | 79 |