フィルターのクリア

legend line color same

6 ビュー (過去 30 日間)
Sean
Sean 2023 年 5 月 21 日
コメント済み: Sean 2023 年 5 月 25 日
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 件のコメント
Sean
Sean 2023 年 5 月 22 日
i want colour of I3 and I2 same as in figure, i.e green and blue
Dyuman Joshi
Dyuman Joshi 2023 年 5 月 22 日
As I requested above, please share you whole code.

サインインしてコメントする。

採用された回答

Nathan Hardenberg
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 件のコメント
Sean
Sean 2023 年 5 月 25 日
thank you, it worked
i used hold on
plot( L_interp, I3, 'g--');
hold on
plot(L_interp, I2, 'b--');

サインインしてコメントする。

その他の回答 (1 件)

Antoni Garcia-Herreros
Antoni Garcia-Herreros 2023 年 5 月 22 日
Hello,
Try:
legend('I3', '','I2');
  1 件のコメント
Sean
Sean 2023 年 5 月 22 日
i tried but got the same result as before.

サインインしてコメントする。

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by