what code to plot dark stairs colors

2 ビュー (過去 30 日間)
pipor
pipor 2023 年 9 月 10 日
コメント済み: Dyuman Joshi 2023 年 9 月 10 日
i use this code di plot n-line
for i=1:r
col=rand(3,1,1)';
hp1=plot(Ax_Eq,XDates,TEE1(i,:),'Color',col);
end
It often happens that light colors are chosen in the color draw
How can I avoid this?
(the random color draw is to avoid confusing the lines or seeing them poorly with a single color

採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 9 月 10 日
Darker colors correspond to the lower range of [0,1] of the RGB scale.
r=5;
str = compose('x^%d',1:r);
hold on
for k=1:r
col = (randi(128,1,3)-1)/255;
fplot(@(x) x.^k, 'Color', col)
end
legend(str)
However, as you can see that it while they are different, it is difficult to easily distinguish between them.
Aternatively, you can use the inbuilt color map available in MATLAB, to have distinct colored plots.
figure
hold on
map = hsv(r);
for k=1:r
fplot(@(x) x.^k, 'Color', map(k,:))
end
legend(str)
You can check out all the available colormaps on the documentation page - colormap and choose according to your liking.
  2 件のコメント
pipor
pipor 2023 年 9 月 10 日
>> c = hsv(m)
Unrecognized function or variable 'm'.
Dyuman Joshi
Dyuman Joshi 2023 年 9 月 10 日
I have not used variable m in my code.
I have used r, which is used in the for loop definition.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by