フィルターのクリア

Different Colors in plotting?

1 回表示 (過去 30 日間)
Seyed Sahand Mohammadi Ziabari
Seyed Sahand Mohammadi Ziabari 2018 年 4 月 24 日
I have this plotting loop and I want to assign different colors to that. Now it considers only the colors that it wants. So, when the number of N increases the colors of some of the graphs are the same so distinguishing between them is really hard. How can I dedicate different colors to the different graphs?
for i=1:N plot(time(1:350),STDX(1:350,i),'lineWidth',3) hold on end
N is the number of the graphs.

回答 (2 件)

Sigurd Askeland
Sigurd Askeland 2018 年 4 月 24 日
The color can be set to a RGB value using the syntax plot(x,y,'color', [r, g, b]), where r, g and b are between 0 and 1. You can generate a (N x 3) color array, and use a row from that in each iteration.
color_array = zeros(n, 3); %Fill this somehow.
for i = 1:n
plot(time, stdx, 'color', color_array(:,i))
end

Seyed Sahand Mohammadi Ziabari
Seyed Sahand Mohammadi Ziabari 2018 年 4 月 24 日
Thanks but it has this error;
Error using plot Color value must be a 3 element vector

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by