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