Legend doesn't match plot
Show older comments
Hello, my legend color doesn't match the color of my plot. I need two diffentent colors in my legend. I have already searched the other questions asked, but none of them seem to work for me.
figure
hold on
% P(1) = plot(x1,a1,'g.',x2,b1,'g.',x3,c1,'g.',x4,d1,'g.','DisplayName','a')
plot(x1,a1,'g.',x2,b1,'g.',x3,c1,'g.',x4,d1,'g.');
errH1 = errorbar(mean(x1), mean(a1), error_LG(1,Rauheitskennwert),'g+');
errH1.LineWidth = 1.2;
errH2 = errorbar(mean(x2), mean(b1), error_LS(1,Rauheitskennwert),'g+');
errH2.LineWidth = 1.2;
errH3 = errorbar(mean(x3), mean(c1), error_LgR(1,Rauheitskennwert),'g+');
errH3.LineWidth = 1.2;
errH4 = errorbar(mean(x4), mean(d1), error_RG(1,Rauheitskennwert),'g+');
errH4.LineWidth = 1.2;
xlim([0.5 4.5])
plot(x1,a_Filter,'.b',x2,b_Filter,'.b',x3,c_Filter,'.b',x4,d_Filter,'.b');
% P(2) = plot(3,a_Filter,'.b',3,b_Filter,'.b',3,c_Filter,'.b',3,d_Filter,'.b','DisplayName','b')
errH6 = errorbar(mean(x1), mean(a_Filter), std(a_Filter),'b+');
errH6.LineWidth = 1.2;
errH7 = errorbar(mean(x2), mean(b_Filter), std(b_Filter),'b+');
errH7.LineWidth = 1.2;
errH8 = errorbar(mean(x3), mean(c_Filter), std(c_Filter),'b+');
errH8.LineWidth = 1.2;
errH9 = errorbar(mean(x4), mean(d_Filter), std(d_Filter),'b+');
errH9.LineWidth = 1.2;
% legendNames = ['a','b'];
% legend(P)
legend('a','b')
2 Comments
Çağlar İŞLEK
on 17 Mar 2021
Hi, Please share your output plot, I will look into it.
LM
on 17 Mar 2021
Accepted Answer
More Answers (0)
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!