Correlating plot's legend and data.

조회 수: 2 (최근 30일)
Yuval
Yuval 2016년 12월 18일
편집: Star Strider 2016년 12월 18일
Hi, I cannot figure out why there's no correlation between the legend and the data's colours in the following code:
figure
subplot(2,1,1)
plot(k,RCS_PO,'k',k,RCS_MOM_soft,'m',k,RCS_MIE_soft,'b','LineWidth',2);
legend('PO','MoM','Mie');
xlabel('$$ ka $$','fontsize',14,'Interpreter','latex');
ylabel('$$ RCS_{2D} [m] $$','fontsize',14,'Interpreter','latex');
The legend's colour bar is black, instead of being black, magenta and blue! Why is that? I realise by now that the problem appears to be with the y matrices, as when they are changed to simple trigonometric functions the output is just fine. But how may these y matrices affect the legend's colours?
  댓글 수: 2
Star Strider
Star Strider 2016년 12월 18일
It works correctly for me in R2016b. It could be a bug in an earlier version.
Contact Support to see if it’s a bug and ask if a fix has been published for it. Include the URL for this thread in your email to them.
Yuval
Yuval 2016년 12월 18일
How may I possibly fix this without having to use a different version? I am using 2016a. Is there any way around this which would still yield the desired result?

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

답변 (1개)

Star Strider
Star Strider 2016년 12월 18일
편집: Star Strider 2016년 12월 18일
I have R2016a installed on this machine, so I brought it up to test this code as a work-sround. It give the desired result, but then so does your original code in R2016a for me.
The Code:
k = 1:20; % Create Testing Data
RCS_PO = rand(1,20);
RCS_MOM_soft = 1+rand(1,20);
RCS_MIE_soft = 2+rand(1, 20);
figure
subplot(2,1,1)
sp1{1} = plot(k,RCS_PO,'k','LineWidth',2);
hold on
sp1{2} = plot(k,RCS_MOM_soft,'m','LineWidth',2);
sp1{3} = plot(k,RCS_MIE_soft,'b','LineWidth',2);
hold off
legend([sp1{:}], 'PO','MoM','Mie');
xlabel('$$ ka $$','fontsize',14,'Interpreter','latex');
ylabel('$$ RCS_{2D} [m] $$','fontsize',14,'Interpreter','latex');
I actually can’t reproduce your problem in either R2016a or R2016b.
EDIT
This just in: ‘the problem appears to be with the y matrices’
Without your actual data to experiment with, we can’t help.

카테고리

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