필터 지우기
필터 지우기

Problem with plotting - legend

조회 수: 1 (최근 30일)
D.J
D.J 2018년 10월 1일
편집: D.J 2018년 10월 1일
Hi all, Any idea how to show the lines in the legend show in the same colour as I defined in my code, black, green, and red? for some reason they all look green ! Here is my code, I also attached the figure. Thank you
plot(T3_All(mask),Tmax_All(mask),'o',T3_All,Res_Lin,'k',T3_All,Res_Pwr,'g', T3_All,Res_Exp,'r'),...
xlabel('T3 (K)'),ylabel('Residuals (K)'),...
legend('Data','Linear','Power','Exponential','location','E')

채택된 답변

Bruno Luong
Bruno Luong 2018년 10월 1일

You probably have more than one curves in each color

hdata = plot(T3_All(mask),Tmax_All(mask),'o');
hlin = plot(T3_All,Res_Lin,'k');
hpwrd = plot(T3_All,Res_Pwr,'g');
hexp = plot(T3_All,Res_Exp,'r');
xlabel('T3 (K)'),ylabel('Residuals (K)');
h = [hdata(1) hlin(1) hpwrd(1) hexp(1)];
legend(h, 'Data','Linear','Power','Exponential','location','E')
  댓글 수: 5
Bruno Luong
Bruno Luong 2018년 10월 1일
편집: Bruno Luong 2018년 10월 1일
So start with my code then replace the random data with your data one by one to see where the problem is.
I think it's somewhere in your code but you don't show us.
D.J
D.J 2018년 10월 1일
편집: D.J 2018년 10월 1일
Guess what Bruno ! your last attempt worked perfectly OK now! I think it was the problem with the "mask". I used your last code, and replaced the "mask" with "isfinite" and it worked ! Thanks a million !

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

추가 답변 (0개)

카테고리

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