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 Center および File ExchangeLegend についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by