legend has same colors

20 ビュー (過去 30 日間)
fadams18
fadams18 2020 年 2 月 17 日
コメント済み: Adam Danz 2020 年 2 月 18 日
Its been asked many times but my code looks fine. I dont know whats making matlab show same colors on the legend
figure(1),
semilogy([1:101],rRE_NeNMF_V','b'),
hold on
semilogy([1:101],rRE_NeNMF_GC','r'),
hold on
semilogy([1:101],rRE_NeNMF_GC_RE','g'),
hold on
semilogy([1:101],rRE_NeNMF_RSI','y'),
axis([0 101 1e-10 1.01])
legend('vanilla','GC','GCRE','RSI')
xlabel('Iterations')
ylabel('RRE')
title('plts of solvers')

採用された回答

Adam Danz
Adam Danz 2020 年 2 月 17 日
編集済み: Adam Danz 2020 年 2 月 18 日
Use the function outputs to get the line object handles. Then, use the object handles in legend().
sem1 = semilogy([1:101],rRE_NeNMF_V','b');
hold on
sem2 = semilogy([1:101],rRE_NeNMF_GC','r');
sem3 = semilogy([1:101],rRE_NeNMF_GC_RE','g');
sem4 = semilogy([1:101],rRE_NeNMF_RSI','y');
axis([0 101 1e-10 1.01])
legend([sem1(1),sem2(1),sem3(1),sem4(1)],'vanilla','GC','GCRE','RSI')
  2 件のコメント
fadams18
fadams18 2020 年 2 月 18 日
thank you
Adam Danz
Adam Danz 2020 年 2 月 18 日
Happy to help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by