Assigning colours to a group of columns when using plot

4 views (last 30 days)
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!!

Accepted Answer

Peng Li
Peng Li on 30 Mar 2020
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.
Phillip Smith
Phillip Smith on 30 Mar 2020
Ah yes that does make sense!
I've got it working now, thank you so much for your help. :)

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!

Translated by