[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Patch to hist for changes in bar
From: |
David Bateman |
Subject: |
Re: Patch to hist for changes in bar |
Date: |
Wed, 25 Apr 2007 23:35:28 +0200 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
John W. Eaton wrote:
> On 25-Apr-2007, David Bateman wrote:
>
> | As bar can now return the figure handle, hist should be slightly
> | changes. See the attached patch
> |
> | D.
> | Index: scripts/plot/hist.m
> | ===================================================================
> | RCS file: /usr/local/cvsroot/octave/scripts/plot/hist.m,v
> | retrieving revision 1.32
> | diff -u -r1.32 hist.m
> | --- scripts/plot/hist.m 10 Oct 2006 16:10:28 -0000 1.32
> | +++ scripts/plot/hist.m 25 Apr 2007 19:00:47 -0000
> | @@ -118,7 +118,7 @@
> | freq = freq / rows (y) * norm;
> | endif
> |
> | - if (nargout > 0)
> | + if (nargout > 1)
> | if (arg_is_vector)
> | nn = freq';
> | xx = x';
> | @@ -127,7 +127,7 @@
> | xx = x;
> | endif
> | else
> | - bar (x, freq);
> | + nn = bar (x, freq, 1.0);
> | endif
> |
> | endfunction
>
> What is the extra 1.0 argument to bar for? It causes an error for me.
>
> Matlab's hist doesn't return anything if nargout == 0.
>
The default bar width in hist is 0.8 and so the bars don't touch. The
old behavior of hist was that the bar width of 1.0 should be used. The
1.0 is the width of the bar.. Compare "bar(1:10,1:10)" against
"bar(1:10,1:10,1.0)". It looks like the error you are seeing is in fact
due to a small error in __bar__.m in that non string arguments or cell
arrays should not be passed to __pltopt__. There was also an issue with
the previous patch as hist(randn(1e6,1)) for example returned the figure
handle even if nargout was zero.
Regards
David
Index: scripts/plot/hist.m
===================================================================
RCS file: /usr/local/cvsroot/octave/scripts/plot/hist.m,v
retrieving revision 1.32
diff -c -r1.32 hist.m
*** scripts/plot/hist.m 10 Oct 2006 16:10:28 -0000 1.32
--- scripts/plot/hist.m 25 Apr 2007 21:30:24 -0000
***************
*** 118,124 ****
freq = freq / rows (y) * norm;
endif
! if (nargout > 0)
if (arg_is_vector)
nn = freq';
xx = x';
--- 118,124 ----
freq = freq / rows (y) * norm;
endif
! if (nargout > 1)
if (arg_is_vector)
nn = freq';
xx = x';
***************
*** 127,133 ****
xx = x;
endif
else
! bar (x, freq);
endif
endfunction
--- 127,137 ----
xx = x;
endif
else
! if (nargout == 1)
! nn = bar (x, freq, 1.0);
! else
! bar (x, freq, 1.0);
! endif
endif
endfunction
*** ./scripts/plot/__bar__.m.orig18 2007-04-25 23:26:28.345582302 +0200
--- ./scripts/plot/__bar__.m 2007-04-25 23:33:17.009468972 +0200
***************
*** 74,80 ****
group = false;
idx++;
else
! if (!HaveLineSpec)
[dummy, valid] = __pltopt__ (func, varargin{idx}, false);
if (valid)
HaveLineSpec = true;
--- 74,80 ----
group = false;
idx++;
else
! if ((isstr(varargin{idx}) || iscell(varargin{idx})) && !HaveLineSpec)
[dummy, valid] = __pltopt__ (func, varargin{idx}, false);
if (valid)
HaveLineSpec = true;
- Patch to hist for changes in bar, David Bateman, 2007/04/25
- Patch to hist for changes in bar, John W. Eaton, 2007/04/25
- Re: Patch to hist for changes in bar,
David Bateman <=
- Re: Patch to hist for changes in bar, John W. Eaton, 2007/04/25
- Re: Patch to hist for changes in bar, David Bateman, 2007/04/25
- Re: Patch to hist for changes in bar, John W. Eaton, 2007/04/26
- Re: Patch to hist for changes in bar, David Bateman, 2007/04/26
- Re: Patch to hist for changes in bar, John W. Eaton, 2007/04/26
- Re: Patch to hist for changes in bar, David Bateman, 2007/04/26