lenend keep only text
23 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
VBBV
2020-11-5
编辑:VBBV
2020-11-5
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'})
更多回答(1 个)
Sylvain
2020-11-5
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 个评论
Sylvain
2020-11-5
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?'})
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!