Color gradient for graph in a for loop
Mostrar comentarios más antiguos
Hi everyone!
I'm plotting 3 force vs displacement plots in the same picture. For one of the lines in the plot, i'd like the color to gradually chance, so to be able to identify the change of the curve throughout the iterations. I would also like the legend of the figure to show a color bar which indicated e.g that the color becomes darker/lighter as the iteration progresses.
So far I have something like this (this is a pseudocode ofc):
fe = 1:0.1:100;
n_freq = length(fe);
for kk= 1:n_freq
[r,z] = ode23s('Nonlin', tspan x0);
x = z(:,1);
F = z(:,2);
F2 = z(:,3);
Ftot = F + F2;
figure(1)
hold on
plot(x, Ftot) %this is the plot which I would like to change gradually per each iteration of the for loop
hold on
plot(x, F)
hold on
plot(x,F2)
end
Can someone help me out? Thanks!
Respuesta aceptada
Más respuestas (1)
Wha about this?
x = [0:.2:10 nan];
y = sin(x);
patch(x,y,y,'edgecolor','interp','linewidth',2)
colorbar
Categorías
Más información sobre Orange en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

