11330
|
1 ## Copyright (C) 2007, 2008, 2009 David Bateman |
|
2 ## Copyright (C) 2010 Kai Habel |
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} pie3 (@var{y}) |
|
22 ## @deftypefnx {Function File} {} pie3 (@var{y}, @var{explode}) |
|
23 ## @deftypefnx {Function File} {} pie3 (@dots{}, @var{labels}) |
|
24 ## @deftypefnx {Function File} {} pie3 (@var{h}, @dots{}); |
|
25 ## @deftypefnx {Function File} {@var{h} =} pie3 (@dots{}); |
|
26 ## Drawa a 3D pie chart. |
|
27 ## |
|
28 ## Called with a single vector argument, produces a 3D pie chart of the |
|
29 ## elements in @var{x}, with the size of the slice determined by percentage |
|
30 ## size of the values of @var{x}. |
|
31 ## |
|
32 ## The variable @var{explode} is a vector of the same length as @var{x} that |
|
33 ## if non zero 'explodes' the slice from the pie chart. |
|
34 ## |
|
35 ## If given @var{labels} is a cell array of strings of the same length as |
|
36 ## @var{x}, giving the labels of each of the slices of the pie chart. |
|
37 ## |
|
38 ## The optional return value @var{h} provides a handle list to patch, surface |
|
39 ## and text objects generating this plot. |
|
40 ## |
|
41 ## @seealso{pie, bar, stem} |
|
42 ## @end deftypefn |
|
43 |
|
44 ## Very roughly based on pie.m from octave-forge whose author was |
|
45 ## Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de> |
|
46 |
|
47 function retval = pie3 (varargin) |
|
48 |
|
49 [h, varargin] = __plt_get_axis_arg__ ("pie", varargin{:}); |
|
50 |
|
51 if (nargin < 1) |
|
52 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 |
|
63 |
|
64 if (nargout > 0) |
|
65 retval = tmp; |
|
66 endif |
|
67 |
|
68 endfunction |
|
69 |
|
70 %!demo |
|
71 %! pie3 ([5:-1:1], [0, 0, 1, 0, 0]); |
|
72 %! colormap([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); |
|
73 |
|
74 %!demo |
|
75 %! pie3 ([3, 2, 1], [0, 0, 1], {"Cheddar", "Swiss", "Camembert"}); |
|
76 %! colormap([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); |
|
77 %! axis ([-2,2,-2,2]); |