Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
plot colours

Subject: plot colours

From: J G

Date: 22 Sep, 2010 23:22:18

Message: 1 of 7

I need to use 13 different colours in a line plot...
1. red
2. green
3. blue
4. yellow
5. cyan
6. black
7. magenta
I've tried using 'orange', 'grey' and other colours I can think of but they don't work.
How can I find out what other colours I can use? (I don't want to use white as that's the background colour). Thanks!

Subject: plot colours

From: Matthew Whitaker

Date: 22 Sep, 2010 23:50:10

Message: 2 of 7

"J G" <jemma.geoghegan@gmail.com> wrote in message <i7e33a$n13$1@fred.mathworks.com>...
> I need to use 13 different colours in a line plot...
> 1. red
> 2. green
> 3. blue
> 4. yellow
> 5. cyan
> 6. black
> 7. magenta
> I've tried using 'orange', 'grey' and other colours I can think of but they don't work.
> How can I find out what other colours I can use? (I don't want to use white as that's the background colour). Thanks!

See doc colorspec
Unfortunately the ones you listed above and white are about it for named colors unless there are some undocumented ones I'm not aware of. However you can always specify the color with an RGB vector.
e.g.
PINK = [1,0.4,0.6];

Hope this helps
Matt W
Matt W

Subject: plot colours

From: Ross W

Date: 22 Sep, 2010 23:51:25

Message: 3 of 7

"J G" <jemma.geoghegan@gmail.com> wrote in message <i7e33a$n13$1@fred.mathworks.com>...
> I need to use 13 different colours in a line plot...
> 1. red
> 2. green
> 3. blue
> 4. yellow
> 5. cyan
> 6. black
> 7. magenta
> I've tried using 'orange', 'grey' and other colours I can think of but they don't work.
> How can I find out what other colours I can use? (I don't want to use white as that's the background colour). Thanks!

There are only 8 predefined colors that have names.

The other way to specify a color using using an RGB triplet. Here's a pink line:

plot(1:10,'color',[1,0.4,0.6])

http://www.mathworks.com/help/techdoc/ref/colorspec.html has the details

Ross

Subject: plot colours

From: J G

Date: 23 Sep, 2010 02:04:06

Message: 4 of 7

Thanks for your help! So for example I should be able to write:

plot(parameter,points2,'green--')
plot(parameter,points3,'blue:')
plot(parameter,points4,'yellow-.')
plot(parameter,points5,'cyan-')
plot(parameter,points6,'black--')
plot(parameter,points7,'magenta:')
plot(parameter,points8,'[1 0.4 0.6]-.')

except there is an 'error in color argument' in the last line when I do... Am I doing this wrong?

Subject: plot colours

From: J G

Date: 23 Sep, 2010 02:29:25

Message: 5 of 7

OK, so this works:

plot(parameter,points8,'color',[1,0.4,0.6])

But how can I specify a line type, e.g. '-' ?
Thanks!

Subject: plot colours

From: Ross W

Date: 23 Sep, 2010 02:46:07

Message: 6 of 7

"J G" <jemma.geoghegan@gmail.com> wrote in message <i7ee25$kqn$1@fred.mathworks.com>...
> OK, so this works:
>
> plot(parameter,points8,'color',[1,0.4,0.6])
>
> But how can I specify a line type, e.g. '-' ?
> Thanks!

plot(parameter,points8,'color',[1,0.4,0.6],'linestyle','-')

http://www.mathworks.com/help/techdoc/ref/linespec.html

Ross

Subject: plot colours

From: J G

Date: 23 Sep, 2010 03:15:29

Message: 7 of 7

Thank you!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us