function LIS_plotcol(L,t1,er,K, E, Ed, Es)
% LIS_plotcol      Make a color plot (in current figure) of the labeling L
%
%  LIS_plotcol(L, t1, er, K, E, Ed, Es)
% -----------------------------------------------------------------------------
%  L    label matrix, IxJ   1 <= L(i,j) <= M (assumed to be 2, 5 or 16)
%  t1   figure title 
%  er   error rate
%  K    number of segments
%  E, Ed, Es    Energy values
% -----------------------------------------------------------------------------

mfile = 'LIS_plotcol';
if nargin < 2
    t1 = ['Figure made by ', strrep(mfile,'_','-'),', ',datestr(now)];
end
if (nargin < 3); er = -1; end;
if (nargin < 4); K = 0; end;
if (nargin < 5); E = -1; end;
if (nargin < 6); Ed = -1; end;
if (nargin < 7); Es = -1; end;
    
cm = [ 10,1,1; ...    % background (0 in L)
        3,6,9; 0,10,2; 9,9,0; ...
        6,0,4; 3,0,7; 0,1,9; ...
        9,0,9; 6,4,0; ...
        1,4,7; 7,4,5; ...
        6,3,9; 2,6,0; 9,6,9; 9,6,3; ...
        5,8,1; ...
        3,9,6; 0,9,9 ]/10;
if er < 0
    ty = '';
else
    ty = ['Errors: ',sprintf('%2.2f',100*er),' %.'];
end
if K > 0
    tx = [int2str(K),' segments. '];
else
    tx = '';
end
if min([E, Ed, Es] >= 0)
    if (Es > 0); lambda=(E-Ed)/Es; else lambda=1; end;
    tx = [tx,'E_d + \lambda E_s = E  :   ',sprintf('%6.4f',Ed),' + ',...
        sprintf('%3.1f  %6.4f = %6.4f', lambda, Es, E),'.'];
end
%
clf; 
image(1+L); 
colormap(cm);
title(strrep(t1,'sigma','\sigma'));
ylabel(ty);
xlabel(tx);

% make png-file
imwrite(1+L,cm,[mfile,'.png'],'png');

return
