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:
(Re)Define Short Names and Long Names for Colors

Subject: (Re)Define Short Names and Long Names for Colors

From: R Wat

Date: 28 Jun, 2013 18:40:10

Message: 1 of 4

There are three ways in which you can typically specify the color of an object in Matlab: RGB vector, short name or long name. Use of the short name (and long name) or more convenient than the RGB vector; however, I'm not a big fan of the predefined colors available. Is there a way to define new short (and long names) of colors? I would also be interested in redefining the current short names to more useful colors. Is this possible?

Thanks!

Subject: (Re)Define Short Names and Long Names for Colors

From: Kirsten

Date: 4 Sep, 2013 18:00:13

Message: 2 of 4

"R Wat" wrote in message <kqklaa$5o5$1@newscl01ah.mathworks.com>...
> There are three ways in which you can typically specify the color of an object in Matlab: RGB vector, short name or long name. Use of the short name (and long name) or more convenient than the RGB vector; however, I'm not a big fan of the predefined colors available. Is there a way to define new short (and long names) of colors? I would also be interested in redefining the current short names to more useful colors. Is this possible?
>
> Thanks!

Did you ever find a solution to this? I would love to change 'g' and 'y' to less fluorescent shades.

Subject: (Re)Define Short Names and Long Names for Colors

From: Steven_Lord

Date: 4 Sep, 2013 18:19:21

Message: 3 of 4



"Kirsten " <kkoehler@jhsph.edu> wrote in message
news:l07sfd$ajv$1@newscl01ah.mathworks.com...
> "R Wat" wrote in message <kqklaa$5o5$1@newscl01ah.mathworks.com>...
>> There are three ways in which you can typically specify the color of an
>> object in Matlab: RGB vector, short name or long name. Use of the short
>> name (and long name) or more convenient than the RGB vector; however, I'm
>> not a big fan of the predefined colors available. Is there a way to
>> define new short (and long names) of colors? I would also be interested
>> in redefining the current short names to more useful colors. Is this
>> possible?
>>
>> Thanks!
>
> Did you ever find a solution to this? I would love to change 'g' and 'y'
> to less fluorescent shades.

You can't change those definitions; those are part of the built-in graphics
source code. [Well, you _could_ theoretically do so, if you got a job here
at MathWorks in the development team that handles the graphics source code.
They are not user-modifiable, though.]

You can do something _like_ what you want, though, by making functions that
return the RGB triplet for your desired color and use that.

h = plot(1:10, 1:10);
yellow = @() [0.9, 0.9, 0];
set(h, 'Color', yellow())

Note that while I used an anonymous function in this example, you could just
as easily make your new color definitions variables, named functions, or
even values in an enumeration class.

http://www.mathworks.com/help/matlab/matlab_oop/enumerations.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: (Re)Define Short Names and Long Names for Colors

From: R Wat

Date: 4 Sep, 2013 20:48:10

Message: 4 of 4

"Steven_Lord" <slord@mathworks.com> wrote in message <l07tj9$skd$1@newscl01ah.mathworks.com>...
>
>
> "Kirsten " <kkoehler@jhsph.edu> wrote in message
> news:l07sfd$ajv$1@newscl01ah.mathworks.com...
> > "R Wat" wrote in message <kqklaa$5o5$1@newscl01ah.mathworks.com>...
> >> There are three ways in which you can typically specify the color of an
> >> object in Matlab: RGB vector, short name or long name. Use of the short
> >> name (and long name) or more convenient than the RGB vector; however, I'm
> >> not a big fan of the predefined colors available. Is there a way to
> >> define new short (and long names) of colors? I would also be interested
> >> in redefining the current short names to more useful colors. Is this
> >> possible?
> >>
> >> Thanks!
> >
> > Did you ever find a solution to this? I would love to change 'g' and 'y'
> > to less fluorescent shades.
>
> You can't change those definitions; those are part of the built-in graphics
> source code. [Well, you _could_ theoretically do so, if you got a job here
> at MathWorks in the development team that handles the graphics source code.
> They are not user-modifiable, though.]
>
> You can do something _like_ what you want, though, by making functions that
> return the RGB triplet for your desired color and use that.
>
> h = plot(1:10, 1:10);
> yellow = @() [0.9, 0.9, 0];
> set(h, 'Color', yellow())
>
> Note that while I used an anonymous function in this example, you could just
> as easily make your new color definitions variables, named functions, or
> even values in an enumeration class.
>
> http://www.mathworks.com/help/matlab/matlab_oop/enumerations.html
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

I like the sounds of your suggestion. I hadn't thought about it, but an enumeration class could work quite well. Thanks so much for the help.

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