function spynum(A,str)
% SPYNUM :  Numerical spy with colormap
%   
% spynum(A) makes a 2D density picture of matrix A
% spynum(A,str) includes string str in the caption (xlabel)
%
% Written 20 Jul 2006 : JRG

if nargin < 2
    str = [];
end;
A = abs(A);
[nra nca] = size(A);
h = mycmap;
colormap(h);
nh = size(h,1);
A = full(A);
Asum = sum(sum(A));
Amin = min(min(A));
Amax = max(max(A));
Aavg = Asum/(nra*nca);
image(A*nh/Amax);
whitebg('k');
axis equal
axis ij
axis([0 nca 0 nra]+.5);
str = sprintf('%smax = %d, min = %d, avg = %3g, total = %d, max/avg = %0.2g', ...
    str, Amax, Amin, Aavg, Asum, Amax/Aavg);
xlabel(str);
colorbar('ytick', [1:(nh-1)/4:nh], 'yticklabel', [0:Amax/4:Amax]);
