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