MATLAB: FaceColor changes automatically in a for loop

facecolorfigurehistogramMATLABplot

I find that the facecolor changes automatically when I use plot in a for loop.
base_color = colormap(lines(10));
x = 1:100;
figure
for i = 1:10
y1 = i*ones(1,length(x));
y2 = i*ones(1,length(x))+0.5;
hold on
plot(x,y1,'LineWidth',1.5,'MarkerFaceColor',base_color(i,:));
plot(x,y2,'LineWidth',1.5,'MarkerFaceColor',base_color(i,:));
end
hold off
It should be the same color for each two lines, but it's not. How can I plot the lines using the designated colors in 'base_color'?
I find not only the 'plot' function, but other functions like 'histogram' will be also like this.
If anyone can help, many thanks!

Best Answer

plot(x,y1,'LineWidth',1.5,'MarkerFaceColor',base_color(i,:));
In the above line the color which you are giving MATLAB is not taking it. So MATLAB is giving color on its own. You have to mention the color you want. Eg:
plot(x,y1,'color','b','LineWidth',1.5); % plot is blue
plot(x,y1,'color',base_color(i,:),'LineWidth',1.5); % in your case