To get the ColorOrder RGB array used for the current axis, get(gca,'ColorOrder') Mpdc10 = distinguishable_colors(10) % 10x3 color map Plot(X(:,ii,1),X(:,ii,2),'.','Color',mpdc10(ii,:)) Īlternatively, using the ColorOrder axis property simplifies the process: X = reshape(X,10,10,2) % for clarity, and to avoid loop Mpdc10 = distinguishable_colors(10) % 10x3 color list X = reshape(X,10,10,2) % for clarity, column is category, row is observation For example, to generate 10 "maximally perceptually-distinct colors" and use them for 10 plots on the same axis (not using ColorOrder): % Starting with X of size 100x2 If the plots exceed the limit of the color order, the color will be repeated. Of course, you can set the ColorOrder for a single axis or simply generate a list of colors to use in any way you like. The color order means that if you plot one variable, MATLAB will give it a default color which will be the first RGB triplet value you get using the get () function. They even made the excellent suggestion to set MATLAB's ColorOrder on startup to, distinguishable_colors(20) The GMPDC submission was chosen on MathWorks' official blog as Pick of the Week a few years ago in part because of the ability to request an arbitrary number of colors (in contrast to MATLAB's built in 7 default colors). Given an initial large list of possible colors, it iteratively chooses the entry in the list that is farthest (in Lab space) from all previously-chosen entries.įor example, here are the colors generated when 25 are requested: This function generates a set of colors which are distinguishable by reference to the "Lab" color space, which more closely matches human color perception than RGB. It is best described in the author's own words: For 10 plots, you obviously cannot rely on the default ColorOrder, so a great way to define N visually distinct colors is with the "Generate Maximally Perceptually-Distinct Colors" (GMPDC) submission on the MATLAB Central File File Exchange. However, by default MATLAB only specifies a short list of colors (just 7 as of R2013b) to cycle through, and on the other hand it can be problematic to find a good set of colors for more data series. The answers mentioning hold all are correct and useful for cycling through the colors specified by the ColorOrder axes property (even though just hold on is now equivalent to hold all).