 <p>You could get rid of all your <code>if/elseif</code> loops:</p> <pre><code>n = size(Y); colour = {'y','m','c','r','g','b','k','r','b','g'}; shape = {'c','c','c','c','c','c','c','s','s','s'}; for ii = 1:n(2) subplot scatter(X(1,ii), X(2,ii), 12, colour{Y(ii)}, shape{Y(ii)}, 'filled') hold on end </code></pre>