lenend keep only text
23 views (last 30 days)
Show older comments
Nikolas Spiliopoulos
on 5 Nov 2020
Commented: Nikolas Spiliopoulos
on 5 Nov 2020
Hi all,
I want to put 3 text phrases in a legend wuth red, green, and blue colour respectively (example: 'one' (red), 'two' (green),'three' (blue))
I have seen a similar question here:
I tried to create the first phrase with red using the following commnads:
dummyh = line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
legend(dummyh,'\color{red}one')
However I cannot add the next 2
could you help me with that?
thanks
0 Comments
Accepted Answer
VBBV
on 5 Nov 2020
Edited: VBBV
on 5 Nov 2020
dummyh = line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
dummyv = line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
dummyz = line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
legend([dummyh dummyv dummyz],{'\color{red}one','\color{green}two','\color{blue}three'})
More Answers (1)
Sylvain
on 5 Nov 2020
dummyh_1= line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');hold on
dummyh_2= line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
dummyh_3= line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
legend([dummyh_1,dummyh_2,dummyh_3], ...
{'One legend entry to rule them all!', 'Yes that s it!','Does it answer your Question?'})
1 Comment
Sylvain
on 5 Nov 2020
Thanks to the answer from @Vasishta, here is an updated verision:
dummyh_1= line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');hold on
dummyh_2= line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
dummyh_3= line(nan, nan, 'Linestyle', 'none', 'Marker', 'none', 'Color', 'none');
legend([dummyh_1,dummyh_2,dummyh_3], ...
{'\color{red}One legend entry to rule them all!', ...
'\color{green}Yes that s it!',...
'\color{blue}Does it answer your Question?'})
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!