フィルターのクリア

Change automatically colors and line style

8 ビュー (過去 30 日間)
Alain
Alain 2014 年 6 月 11 日
編集済み: Ilham Hardy 2014 年 6 月 12 日
Hello,
I'm sure my question has already been asked but I wasn't able to find it.
I'm plotting several functions in a loop such as:
for n=1:10
[Y{1,n},V]=f_regression(M(n,:),k,1);
hold all
h(n)=plot(V(:,i),Y{1,n}(:,i));
end
I want each function to have its own color. hold all changes ideed the color but a lot of them are the same color.
Is it possible to have strictly different colors or maybe change the line style when the color is the same?
Thanks for helping.

採用された回答

Ilham Hardy
Ilham Hardy 2014 年 6 月 11 日
編集済み: Ilham Hardy 2014 年 6 月 12 日
Hi Alain,
The hold all command used the ColorOrder .
By default there are only 7 elements (read: colors) defined in the ColorOrder , thus 7 repeated consecutive colors.
You can define your custom ColorOrder for specific figure (axis).
For example,
% check default ColorOrder
ColorOdrDef = get(gca,'ColorOrder'); %7x3 RGB array
%define your custom color order
ColorOdrCustom = [0 0 1;...
0 1 0;...
1 0 0;...
0 1 1;...
1 0 1;...
1 0.69 0.39;...
0.6 0.2 0;...
0 0.75 0.75;...
0.22 0.44 0.34;...
0.32 0.19 0.19]; %10x3 RGB array
set(gca,'ColorOrder',ColorOdrCustom);
Hope that helps,
  1 件のコメント
Alain
Alain 2014 年 6 月 12 日
Thank you. I can choose my colors now. I imagine it's quite the same with the LineStyleOrder. I think I prefer changing both colors and linestyle. I'll try it. Thanks.

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

その他の回答 (1 件)

Henric Rydén
Henric Rydén 2014 年 6 月 11 日
Yes it's possible. Check the predefined colormaps here:
colors = jet(10);
for n=1:10
[Y{1,n},V]=f_regression(M(n,:),k,1);
hold all
h(n)=plot(V(:,i),Y{1,n}(:,i),'Color',colors(n,:));
end
  1 件のコメント
Alain
Alain 2014 年 6 月 12 日
Yes, it's great. There are some colors that I don't really like because it's too light. But it's helpfull. Thanks.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by