フィルターのクリア

Assigning colours to a group of columns when using plot

3 ビュー (過去 30 日間)
Phillip Smith
Phillip Smith 2020 年 3 月 30 日
コメント済み: Phillip Smith 2020 年 3 月 30 日
Hey everyone,
I'm potting a matrix(M) with 50 columns. Everything plots well enough, what I want is for the first 10 columns of lines to have one colour, the second to have another etc. This is to make the groups of columns identifiable on the plot because at the moment it's 50 curves with varying colours. I have tried,
p(1:10).colour = 'red';
but Matlab doens't seem to like it.
If anyone could lend a hand I'll really appreciate it!!
Phill

採用された回答

Peng Li
Peng Li 2020 年 3 月 30 日
Dot indexing doesn't support this. You can use set(p(1:10), 'Color', 'red'); instead.
A further note is that when you use dot indexing, you have to use the property name exactly and case sensitively which is Color in matlab not colour.
  3 件のコメント
Peng Li
Peng Li 2020 年 3 月 30 日
well I used p because in your question you used p. I thought that represents your figure handles.
So what did you use when you plot your data? You should use that as well.
For example
p = plot([1 2 3]);
set(p, 'Color', 'red');
in this case, as there is only a single instance, you can use dot indexing p.Color = 'red';
Phillip Smith
Phillip Smith 2020 年 3 月 30 日
Ah yes that does make sense!
I've got it working now, thank you so much for your help. :)
Phill

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by