legend line color same
    조회 수: 7 (최근 30일)
  
       이전 댓글 표시
    
 How to get different color in legend, getting same dashed green color for I3,I2 , should be as plotted I3 green and I2 to be blue
How to get different color in legend, getting same dashed green color for I3,I2 , should be as plotted I3 green and I2 to be blue disp(f2);
plot( L_interp, I3, 'g--' ,L_interp, I2, 'b--',L_interp, I4, 'r--',L_interp, I, 'k--');
xlabel('wavelength');
ylabel('I');
legend('I3', 'I2');
Thank you
댓글 수: 4
채택된 답변
  Nathan Hardenberg
      
 2023년 5월 22일
        Your Code should work. I simplified it and ran it here (see below).
You can try the following:
clear  % run this
clear 'all'  % and also try this
% before you plot make a line like this (this forces a new figure)
figure(10); hold on; grid on; clf;
And also try restarting Matlab. If this also does not help you have to provide the whole code (as already suggested). Maybe you plot I3 before for some reason. This can be tested: Just enter more names in the legend:
legend('test1', 'test2', 'test3', 'test4', 'test5', 'test6', 'test7', 'test8')
The Code that works:
L_interp = linspace(0,10,10);
I3 = rand(1,10);
I2 = rand(1,10);
plot(L_interp, I3, 'g--', L_interp, I2, 'b--');
xlabel('wavelength');
ylabel('I');
legend('I3', 'I2');
추가 답변 (1개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





