필터 지우기
필터 지우기

lenend keep only text

조회 수: 15 (최근 30일)
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2020년 11월 5일
댓글: Nikolas Spiliopoulos 2020년 11월 5일
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

채택된 답변

VBBV
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
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2020년 11월 5일
thanks a lot, it works!!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sylvain
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
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 CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by