How to plot multiple fitted curves in single plot with different colors and legends
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi all,
I am trying to plot multiple fitted curves in single plot using for loop. I wish to have different colors for each plot (or atleast for each fitted line) along with all legends.
Kindly help!
Thanks!
for cf = 1:3
AHG_final; % a, b and Name comes from 'AHG_final' script
loga = log(a);
fitc = fit(loga',b','poly1');
plot(fitc,loga',b');legend(['River',sprintf(' %d : ', cf), sprintf( Name)]);
xlabel('log a'); ylabel('b'); title(['River',sprintf(' %d : ', cf), sprintf( Name)]);
hold on;
end
0 Commenti
Risposte (1)
Serhii Tetora
il 20 Lug 2020
You can predefine your colors for example as
colors = {'r','g','b'};
% or
colors = colormap(jet(3));
% etc.
and than in loop
h = plot(fitc,loga',b');
set(h,'Color',colors{i});
0 Commenti
Vedere anche
Categorie
Scopri di più su Legend in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!