Mercurial > hg > octave-lyh
changeset 17168:6e8c621c3496
pareto.m: Accept an axis handle as first input.
* scripts/plot/pareto.m: Use __plt_axis_get_arg__ to accept an axis handle as
first input.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 02 Aug 2013 17:35:52 -0700 |
parents | d74e2b5bdeb5 |
children | 52931d71400f |
files | scripts/plot/pareto.m |
diffstat | 1 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/pareto.m +++ b/scripts/plot/pareto.m @@ -64,6 +64,8 @@ function h = pareto (varargin) + [hax, varargin, nargin] = __plt_get_axis_arg__ ("pareto", varargin{:}); + if (nargin != 1 && nargin != 2) print_usage (); endif @@ -84,23 +86,29 @@ endif [x, idx] = sort (x, "descend"); - y = y (idx); + y = y(idx); cdf = cumsum (x); maxcdf = max (cdf); cdf = cdf ./ maxcdf; cdf95 = cdf - 0.95; idx95 = find (sign (cdf95(1:end-1)) != sign (cdf95(2:end)))(1); - [ax, hbar, hline] = plotyy (1 : idx95, x (1 : idx95), - 1 : length (cdf), 100 .* cdf, - @bar, @plot); + if (isempty (hax)) + [ax, hbar, hline] = plotyy (1 : idx95, x (1 : idx95), + 1 : length (cdf), 100 .* cdf, + @bar, @plot); + else + [ax, hbar, hline] = plotyy (hax, 1 : idx95, x (1 : idx95), + 1 : length (cdf), 100 .* cdf, + @bar, @plot); + endif axis (ax(1), [1 - 0.6, idx95 + 0.6, 0, maxcdf]); axis (ax(2), [1 - 0.6, idx95 + 0.6, 0, 100]); set (ax(2), "ytick", [0, 20, 40, 60, 80, 100], - "yticklabel", {"0%", "20%", "40%", "60%", "80%", "100%"}); - set (ax(1), "xtick", 1 : idx95, "xticklabel", y (1: idx95)); - set (ax(2), "xtick", 1 : idx95, "xticklabel", y (1: idx95)); + "yticklabel", {"0%", "20%", "40%", "60%", "80%", "100%"}); + set (ax(1), "xtick", 1:idx95, "xticklabel", y(1:idx95)); + set (ax(2), "xtick", 1:idx95, "xticklabel", y(1:idx95)); if (nargout > 0) h = [hbar; hline];