Matlab by default has 7 colors. Following code demonstrates how one can invoke plot command within a for loop so that each time it plots a given data set in a different color. Don't worry about the variables that are used in this piece of code. You should notice that we can pass randomized color information to the plot command inside a for loop.
hold on;
for k = 1:length(idx)
ridx = find(idx == k);
color = rand(1,3);
for j = 1:length(ridx);
plot(logdata(:,1,ridx(j)),logdata(:,2,ridx(j)), ...
'Color',color,'LineWidth',2);
end
end
hold off;
Subscribe to:
Post Comments (Atom)
2 comments:
This is how you can change the default color order in plot
>> set(gcf,'DefaultAxesColor',[1 0 0; 0 1 0; 0 0 1; 1 1 0]);
>> plot(data(:,1:2;7),data(:,2:2:8),'LineWidth',2)
Another option would to use "varycolor" program written by Daniel Helmick. It provides a better interface to deal with multiple colors.
Post a Comment