Legend not using the same colors as the plots?
조회 수: 1 (최근 30일)
이전 댓글 표시
I'm running this code and need to make a legend. However the legend colors is not the same as the plot colors, even though they are in order. There is also one part of the legend with a gray color, despite not having any gray in the code. Here is part of the code:
ind=find(T_test==0.4986);
loglog(T_test(ind),p_val(ind),'o:', 'color', 'c', ...
'markersize', 3, 'markerfacecolor', 'c', ...
'MarkerEdgeColor', 'c');
ind1=find(T_test==1.0028);
loglog(T_test(ind1),p_val(ind1),'o:', 'color', 'b', ...
'markersize', 3, 'markerfacecolor', 'b', ...
'MarkerEdgeColor', 'b');
ind2=find(T_test==1.0758);
loglog(T_test(ind2),p_val(ind2),'o:', 'color', 'r', ...
'markersize', 3, 'markerfacecolor', 'r', ...
'MarkerEdgeColor', 'r');
ind3=find(T_test==0.9973);
loglog(T_test(ind3),p_val(ind3),'o:', 'color', 'g', ...
'markersize', 3, 'markerfacecolor', 'g', ...
'MarkerEdgeColor', 'g');
ind4=find(T_test==0.5274);
loglog(T_test(ind4),p_val(ind4),'o:', 'color', 'y', ...
'markersize', 3, 'markerfacecolor', 'y', ...
'MarkerEdgeColor', 'y');
ind5=find(T_test==0.5175);
loglog(T_test(ind5),p_val(ind5),'o:', 'color', 'k', ...
'markersize', 3, 'markerfacecolor', 'k', ...
'MarkerEdgeColor', 'k');
ind6=find(T_test==0.5);
loglog(T_test(ind6),p_val(ind6),'o:', 'color', 'm', ...
'markersize', 3, 'markerfacecolor', 'm', ...
'MarkerEdgeColor', 'm');
ind7=find(T_test==1);
loglog(T_test(ind7),p_val(ind7),'o:', 'color', 'y', ...
'markersize', 10, 'markerfacecolor', 'y', ...
'MarkerEdgeColor', 'y');
legend('K2','P1','O1','K1','N2','M2','S2','S1','location','northwest')
Basically I am using 7 colors, with yellow being used twice. Why is the legend not agreeing with this? Thanks
댓글 수: 0
답변 (2개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!