MATLAB: How to fix the colors of a subplot

colordefaultaxescolororderMATLABplotplotyysubplot

Hello!
I have a matlab figure with a 4*2 subplot. In the first row I have 8 lines ploted and in the second 4. For the first row I have 4 lines refered to a left Y axis and 4 to the right Y axis (plotyy). I want the colors to be mantained,that is, the first line of right and left to be f.ex. red the second pink etc.
As for the second,third and forth row I have For the first row I have 2 lines refered to a left Y axis and 2 to the right Y axis. And want also the fist lines of right and left red etc.
I´ve been tryfing to set the colors with
set(gcf,'DefaultAxesColorOrder',[1 0 0;0 1 0;0 0 1;0 0 0]);
but it works only for the first row. In the second I get each line of a diferent color instead of two lines(rigt and left) of each color.
Thanks

Best Answer

Set it for each axes just after you call subplot() and just before you call plot():
% Apply the new default colors to the current axes.
set(gca, 'ColorOrder', newDefaultColors, 'NextPlot', 'replacechildren');
See attached color order demo below.