function h = plotdata(X,c);

% plot data, coloring according to cluster labels.


if max(c) > 1
  K = max(c);
  col = colormap;
  col = col(ceil((.5:K)/K*size(col,1)),:);
  h = zeros(1,K);
  for k=1:K
    i = find(c==k);
    h(k) = plot(X(i,1),X(i,2),'.','markersize',10,'color',col(k,:));
    hold on
  end
  hold off
else
  r = c;
  K = size(r,2);
  m = size(X,1);
  col = colormap;
  col = col(ceil((.5:K)/K*size(col,1)),:);
  h = zeros(1,m);
  for i = 1:m
    h(i) = plot(X(i,1),X(i,2),'.','markersize',10,'color',min(r(i,:)*col,1));
    hold on
  end
end



