Filter löschen
Filter löschen

Correlating plot's legend and data.

1 Ansicht (letzte 30 Tage)
Yuval
Yuval am 18 Dez. 2016
Bearbeitet: Star Strider am 18 Dez. 2016
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 Kommentare
Star Strider
Star Strider am 18 Dez. 2016
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 am 18 Dez. 2016
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?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 18 Dez. 2016
Bearbeitet: Star Strider am 18 Dez. 2016
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.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by