function cmap = clabel2colormap(C, doColormap)
if ~exist('doColormap', 'var') || isempty(doColormap)
    doColormap = false;
end

nc = numel(unique(C));
cmap = distinguishable_colors(nc, repmat(linspace(0,1,2)',1,3));

if doColormap
    colormap(cmap);
end

% if ~exist('doColormap', 'var') || isempty(doColormap)
%     doColormap = false;
% end
% pre_cmap = predefined_colors;
% npre = size(pre_cmap,1);
% 
% nc = length(unique(C));
% if nc<=npre
%     cmap = pre_cmap(1:nc,:);
% else
%     rand('seed',0);
%     cmap = rand(nc,3);    
% end
% if doColormap
%     colormap(cmap);
% end