Plotting 20-100 line with different distinguishable colors and shades on the same figure using a for loop
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to plot multiple data lines point on the same figure by executing a for loop (see below) which should plot one line per iteration for 10, 20, or 100 iterations . The problem is that the default setting output only 7 colors, so there are about lines of the same color for 2-3 iterations per figure (Please see example figure attached for clarification). I researched and found that the function "distinguishable_colors" is supposed to increase the variation in the colors for a wider range, and thus fits my purpose. However, I'm having problems executing the code with that function. I'd appreciate your help to make it work. Thank you.
%.<---...some code....
PixelCountLast10(PixelCountLast10==0)=NaN;
ColMap=distinguishable_colors(20);
figure(FigLast10)
for TrialLast10=PlotInitValLast10:StartInt:LastFrameLast10;
IterationNoLast10=(TrialLast10-1)./800+1;
txtLast10=['Trial',num2str(IterationNoLast10)];
p1=plot(PixelCountLast10((TrialLast10):((TrialLast10)+449)),'DisplayName',txtLast10),'Color',ColMap(TrialLast10,:)); %I get error here
hold on;
Max_ylimLast10= max(PixelCountLast10)+150;
Min_ylimLast10=min(PixelCountLast10)-150;
hold on;
end
%...some code..-->
0 Kommentare
Antworten (1)
Mehmed Saad
am 25 Jun. 2020
Bearbeitet: Mehmed Saad
am 25 Jun. 2020
Try the following strategy
cmp=distinguishable_colors(20);
f=figure;
ax = gca(f);ax.ColorOrder = cmp;
hold on;
A = rand(100,20)+(1:20);
for ii =1:20
plot(A(:,ii))
end
hold off
0 Kommentare
Siehe auch
Kategorien
Mehr zu Orange finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!