How can I set the color of text in a legend to match its corresponding line color in a MATLAB figure and change the Font size?
5 views (last 30 days)
Show older comments
Hi, how can I change the color of the text for the legend so that each label matches its corresponding line color and the Font Size can be changed?
I would like to use this code:
[h, ~, plots] = legend('sin(x)', 'cos(x)');
for idx = 1:length(h.String)
h.String{idx} = ['\color[rgb]{' num2str(plots(idx).Color) '} ' h.String{idx}]
end
But now I can not change the Font Size anymore! Can you give me an example how I can change the Font Size of the text in the legend?
Thanks for your support.
0 Comments
Answers (0)
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!