legends after each iteration
1 view (last 30 days)
Show older comments
want to add legends after each iteration in a for loop ?
any suggestions ??
1 Comment
the cyclist
on 28 Sep 2015
This is not twitter. Can you please write out a more complete explanation of what you want? How you have written this, there is too much guesswork for us.
Answers (1)
Walter Roberson
on 28 Sep 2015
legend_strings = {};
for K = 1 : 20
h(K) = plot(rand(1,10)); %produce the plot to be legend'd and save the handle
hold on
legend_strings{K} = sprintf('Run #%d', K); %construct the string that is the legend
legend(h(1:K), legend_strings(1:K)); %update the legends
drawnow(); %make the change visible
end
0 Comments
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!