function cmplot (c, idx, st)
%CMPLOT  Comparison plot

[nseg, out] = collect;
if nargin < 3, st = out(2); end % test error
assert(any(st == out));
c = c(:,st:nseg:end);

pat = {'k', 'b', 'g-', 'm-', 'r:', 'r--', 'r-.', 'b:', 'b--', 'b-.'};
liw = [.5 1 .6 1.4 2 1.3 1.5 1 .5 .6];

figure; hold on; grid off; box on;
if any(st == out(3))
    set(gca, 'YScale', 'Log');
end
leg = '';
for id = idx
    i = mod(id-1, (size(c,1)/4)) + 1;
    h = plot(c(id,:), pat{i}, 'LineWidth', liw(i));
    if strfind(pat{i}, 'g'), set(h, 'Color', [0 .5 0]); end
    switch i
      case 1,  leg = [leg ',''one-vs-one'''];
      case 2,  leg = [leg ',''one-vs-all'''];
      case 3,  leg = [leg ',''AdaBoost.ECC (rand-half)'''];
      case 4,  leg = [leg ',''AdaBoost.ECC (max-cut)'''];
      case 5,  leg = [leg ',''AdaBoost.ERP (max-2, LR)'''];
      case 6,  leg = [leg ',''AdaBoost.ERP (max-2, LRL)'''];
      case 7,  leg = [leg ',''AdaBoost.ERP (max-2, LRLR)'''];
      case 8,  leg = [leg ',''AdaBoost.ERP (rand-2, LR)'''];
      case 9,  leg = [leg ',''AdaBoost.ERP (rand-2, LRL)'''];
      case 10, leg = [leg ',''AdaBoost.ERP (rand-2, LRLR)'''];
    end
end
eval(['legend(' leg(2:end) ');']);
xlabel('Number of iterations', 'FontWeight', 'demi');
if st == out(1)
    ylabel('Training error (%)', 'FontWeight', 'demi');
elseif st == out(2)
    ylabel('Test error (%)', 'FontWeight', 'demi');
elseif st == out(3)
    ylabel('Training cost (normalized)', 'FontWeight', 'demi');
end
