Correlating plot's legend and data.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Star Strider
le 18 Déc 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.
Réponses (1)
Star Strider
le 18 Déc 2016
Modifié(e) : Star Strider
le 18 Déc 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.
0 commentaires
Voir également
Catégories
En savoir plus sur Legend dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!