[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bar and hist
From: |
David Bateman |
Subject: |
Re: bar and hist |
Date: |
Tue, 06 Nov 2007 23:40:30 +0100 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
Opps, the patch needed an update for the test code, an so use the
attached patch instead. I checked matlabR2007a an the new behavior is
the one that matlab supports.
D.
*** ./scripts/plot/hist.m.orig3 2007-11-06 13:56:45.263951652 +0100
--- ./scripts/plot/hist.m 2007-11-06 23:32:06.791039731 +0100
***************
*** 43,51 ****
## Author: jwe
! function [nn, xx] = hist (y, x, norm)
! if (nargin < 1 || nargin > 3)
print_usage ();
endif
--- 43,51 ----
## Author: jwe
! function [nn, xx] = hist (y, varargin)
! if (nargin < 1)
print_usage ();
endif
***************
*** 56,73 ****
endif
if (isreal (y))
! max_val = max (y);
! min_val = min (y);
else
error ("hist: first argument must be a vector");
endif
! if (nargin == 1)
n = 10;
x = [0.5:n]'/n;
x = x * (max_val - min_val) + ones(size(x)) * min_val;
else
## nargin is either 2 or 3
if (isscalar (x))
n = x;
if (n <= 0)
--- 56,75 ----
endif
if (isreal (y))
! max_val = max (y(:));
! min_val = min (y(:));
else
error ("hist: first argument must be a vector");
endif
! iarg = 1;
! if (nargin == 1 || ischar (varargin{iarg}))
n = 10;
x = [0.5:n]'/n;
x = x * (max_val - min_val) + ones(size(x)) * min_val;
else
## nargin is either 2 or 3
+ x = varargin {iarg++};
if (isscalar (x))
n = x;
if (n <= 0)
***************
*** 113,120 ****
freq = diff (chist);
! if (nargin == 3)
## Normalise the histogram.
freq = freq / rows (y) * norm;
endif
--- 115,123 ----
freq = diff (chist);
! if (nargin > 2 && !ischar (varargin{iarg}))
## Normalise the histogram.
+ norm = varargin{iarg++};
freq = freq / rows (y) * norm;
endif
***************
*** 126,133 ****
nn = freq;
xx = x;
endif
else
! bar (x, freq, 1.0);
endif
endfunction
--- 129,138 ----
nn = freq;
xx = x;
endif
+ elseif (size (freq, 2) != 1)
+ bar (x, freq, 0.8, varargin{iarg:end});
else
! bar (x, freq, 1.0, varargin{iarg:end});
endif
endfunction
***************
*** 146,152 ****
%! assert(nn, [3,2,1]);
%!test
%! [nn,xx]=hist([[1:4]',[1:4]'],3);
! %! assert(xx, [[1.5,2.5,3.5]',[1.5,2.5,3.5]']);
%! assert(nn, [[2,1,1]',[2,1,1]']);
%!assert(hist(1,1),1);
%!test
--- 151,157 ----
%! assert(nn, [3,2,1]);
%!test
%! [nn,xx]=hist([[1:4]',[1:4]'],3);
! %! assert(xx, [1.5;2.5;3.5]);
%! assert(nn, [[2,1,1]',[2,1,1]']);
%!assert(hist(1,1),1);
%!test
2007-11-06 David Bateman <address@hidden>
* plot/hist.m: Pass any additional arguments to bar for
treatment. Create a default x value that is always a vector.
Re: bar and hist, David Bateman, 2007/11/05
- Re: bar and hist, Evan, 2007/11/06
- Re: bar and hist, David Bateman, 2007/11/06
- Re: bar and hist, Kai Habel, 2007/11/06
- Re: bar and hist, David Bateman, 2007/11/06
- Re: bar and hist,
David Bateman <=
- Re: bar and hist, John W. Eaton, 2007/11/06
- Re: bar and hist, David Bateman, 2007/11/06
- Re: bar and hist, David Bateman, 2007/11/06