Setting colors for plot function
13 ビュー (過去 30 日間)
古いコメントを表示
I would like to be able to choose the colors for a multiline plot but I can not get it. This is my code
colors = {'b','r','g'};
T = [0 1 2]';
column = [2 3];
count = magic(3);
SelecY = count(:,column),
plot(T,SelecY,'Color',colors{column});
0 件のコメント
採用された回答
Image Analyst
2011 年 11 月 3 日
See my demo for setting ColorOrder here: http://www.mathworks.com/matlabcentral/answers/19815-explicitly-specifying-line-colors-when-plotting-a-matrix
その他の回答 (1 件)
Walter Roberson
2011 年 11 月 3 日
You cannot specify different colors in multi-column (multi-line) plot() calls.
You can record the handles and set the colors individually:
h = plot(T,SelecY);
for K = 1 : length(h)
set(h,'Color', colors{column(K)});
end
Another approach is use the axes ColorOrder property. See here. (Note: you need RGB color specifications for that approach.)
2 件のコメント
Walter Roberson
2011 年 11 月 5 日
That sounds unlikely to be the case, but I do not have access to MATLAB this evening to test it out.
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!