Hello,

hist2d.m in the package plot-1.0.4 has the following problems:

(minor) Not all output arguments are defined
(minor) The usage message does not describe the calling structure
(major) the x- and y-axes on the output are swapped.

To see the major bug, do the following:
        > x = rand(1e6,1); hist(x);  # a flat histogram on [0,1]
        > y = randn(1e6,1); hist(y);         # a gaussian on [-4,4] or so
        > hist2d([x,y]);             # the axes go the wrong way
        > hist2d([x,y], 10,20);              # dies with a size error

The attached patch addresses all these issues. I chose return arguments that may be passed to mesh() or contour(), in the same way that the outputs of hist() may be passed to bar().

Cheers,
Rob

--
Rob Mahurin
Dept. of Physics & Astronomy
University of Tennessee         phone: 865 207 2594
Knoxville, TN 37996             email: [EMAIL PROTECTED]

--- hist2d.m~   2008-04-01 12:30:38.000000000 -0600
+++ hist2d.m    2008-04-01 13:32:54.000000000 -0600
@@ -9,9 +9,9 @@
 % Author: Paul Kienzle
 % This code is public domain.
 
-function [ret_counts, xmid, ymid] = hist2d(M,xbins,ybins)
+function [ret_counts, xbins, ybins] = hist2d(M,xbins,ybins)
 
-  if nargin < 1 && nargin > 3, usage("[nn,xx] = hist2d (M,x,y)"); end
+  if nargin < 1 && nargin > 3, usage("[nn,xx,yy] = hist2d (M,x,y)"); end
 
   lo = min(M);
   hi = max(M);
@@ -38,8 +38,8 @@
   counts = sparse(xidx,yidx,1,length(xbins),length(ybins),'sum');
 
   if nargout
-    ret_counts = full(counts);
+    ret_counts = full(counts');
   else
-    mesh(xbins,ybins,full(counts));
+    mesh(xbins,ybins,full(counts'));
   end
 end
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to