Mercurial > hg > octave-avbm
changeset 11341:3c7ba1e3dc21
Add missing option slice for pie and pie3
author | Kai Habel <kai.habel@gmx.de> |
---|---|
date | Fri, 10 Dec 2010 19:53:06 +0100 |
parents | ef65ebb325e9 |
children | cc7f30d3fd01 |
files | scripts/ChangeLog scripts/plot/pie.m scripts/plot/pie3.m scripts/plot/private/__pie__.m |
diffstat | 4 files changed, 38 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,9 @@ +2010-12-10 Kai Habel <kai.habel@gmx.de> + + * plot/private/__pie__.m: Add missing slice option to pie and + pie3 function. + * plot/pie.m, plot/pie3.m: Add new demo. + 2010-12-10 Thorsten Meyer <thorsten.meyier@gmx.de> * statistics/tests/kolmogorov_smirnov_test.m: Add tests.
--- a/scripts/plot/pie.m +++ b/scripts/plot/pie.m @@ -17,8 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} pie (@var{y}) -## @deftypefnx {Function File} {} pie (@var{y}, @var{explode}) +## @deftypefn {Function File} {} pie (@var{x}) +## @deftypefnx {Function File} {} pie (@var{x}, @var{explode}) ## @deftypefnx {Function File} {} pie (@dots{}, @var{labels}) ## @deftypefnx {Function File} {} pie (@var{h}, @dots{}); ## @deftypefnx {Function File} {@var{h} =} pie (@dots{}); @@ -73,3 +73,9 @@ %! pie ([3, 2, 1], [0, 0, 1], {"Cheddar", "Swiss", "Camembert"}); %! colormap([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); %! axis ([-2,2,-2,2]); + +%!demo +%! pie ([0.17, 0.34, 0.41], {"Cheddar", "Swiss", "Camembert"}); +%! colormap([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); +%! axis ([-2,2,-2,2]); +%! title ("missing slice"); \ No newline at end of file
--- a/scripts/plot/pie3.m +++ b/scripts/plot/pie3.m @@ -18,8 +18,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} pie3 (@var{y}) -## @deftypefnx {Function File} {} pie3 (@var{y}, @var{explode}) +## @deftypefn {Function File} {} pie3 (@var{x}) +## @deftypefnx {Function File} {} pie3 (@var{x}, @var{explode}) ## @deftypefnx {Function File} {} pie3 (@dots{}, @var{labels}) ## @deftypefnx {Function File} {} pie3 (@var{h}, @dots{}); ## @deftypefnx {Function File} {@var{h} =} pie3 (@dots{}); @@ -75,3 +75,9 @@ %! pie3 ([3, 2, 1], [0, 0, 1], {"Cheddar", "Swiss", "Camembert"}); %! colormap([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); %! axis ([-2,2,-2,2]); + +%!demo +%! pie3 ([0.17, 0.34, 0.41], {"Cheddar", "Swiss", "Camembert"}); +%! colormap([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); +%! axis ([-2,2,-2,2]); +%! title ("missing slice"); \ No newline at end of file
--- a/scripts/plot/private/__pie__.m +++ b/scripts/plot/private/__pie__.m @@ -61,8 +61,17 @@ explode = zeros (size (x)); endif + normalize = true; + if (sum (x(:)) < 1) + normalize = false; + endif + if (! have_labels) - xp = round (100 * x ./ sum (x)); + if (normalize) + xp = round (100 * x ./ sum (x)); + else + xp = round (100 * x); + endif for i = 1:len labels{i} = sprintf ("%d%%", xp(i)); endfor @@ -71,7 +80,12 @@ hlist = []; refinement = 90; phi = 0:refinement:360; - xphi = cumsum (x / sum (x) * 360); + if (normalize) + xphi = cumsum (x / sum (x) * 360); + else + xphi = cumsum (x * 360); + endif + for i = 1:len if (i == 1) xn = 0 : 360 / refinement : xphi(i);