different colors for variable legend

2 ビュー (過去 30 日間)
Ashi Khajotia
Ashi Khajotia 2023 年 5 月 24 日
コメント済み: Dongyue 2023 年 5 月 26 日
Hello there,
So, I have used variable legend in my code and the values are about 10 but the colors are repeating itself, I am looking for a method another than specifying colors for every different variable myself. Your suggestions will help. Thank you!
  2 件のコメント
Dongyue
Dongyue 2023 年 5 月 26 日
Hi Ashi,
Could you please provide additional context and details regarding the problem you are encountering? It would be helpful to include specific code or plots.
If you are working with a plot in MATLAB, the software automatically assigns different colors to distinct variables, eliminating the need for manually specifying colors for each variable. Here is a basic example:
x= linspace(0,2*pi);
y1 = sin(x);
y2 = cos(x);
plot(x,y1)
hold on
plot(x,y2)
hold off
legend('sin(x)','cos(y)')
And here is a link to the colormap function, which could be useful for your situation:

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

回答 (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