how can i get same color graph in each iteration of for loop?
Mostra commenti meno recenti
In my Matlab code, I am trying to merge two graphs in each iteration of for loop. I want the color of graph generated to be same for an iteration, but varying color with iteration
Risposta accettata
Più risposte (2)
Christopher Coello
il 7 Feb 2018
Use the property Color when you plot the figure and the colormap of your choice (parula post 2014b, jet before)
g = randn(12,150);
h = randn(12,150)+5;
figure;c_map = parula(12);
for iR = 1:12
hAx=subplot(4,3,iR);hold(hAx,'on');
plot(g(iR,:),'Color',c_map(iR,:));
plot(h(iR,:),'Color',c_map(iR,:));
end
Sree Harsha Bhimineni
il 20 Giu 2021
You can use a random function as follows:
for i=1:1:10
v = rand(3,1);
plot(X1,Y1,'Color',v);
hold on
plot(X2,Y2,'Color',v);
end
Categorie
Scopri di più su Graph and Network Algorithms in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!