Matlab – Reset ColorOrder index for plotting in Matlab / Octave

matlaboctaveplot

I have matrices x1, x2, ... containing variable number of row vectors.
I do successive plots

figure
hold all % or hold on
plot(x1')
plot(x2')
plot(x3')

Matlab or octave normally iterates through ColorOrder and plot each line in different color. But I want each plot command to start again with the first color in colororder, so in default case the first vector from matrix should be blue, second in green, third in red etc.

Unfortunately I cannot find any property related to the color index niether another method to reset it.

Best Solution

Starting from R2014b there's a simple way to restart your color order.

Insert this line every time you need to reset the color order.

set(gca,'ColorOrderIndex',1)

or

ax = gca;
ax.ColorOrderIndex = 1;

see: http://au.mathworks.com/help/matlab/graphics_transition/why-are-plot-lines-different-colors.html

Related Question