File Exchange

image thumbnail

Multilanguage Color Management Class

version (39.8 KB) by Adil Sbai
A Color class which facilitates color management in MATLAB 2D/3D graphics.

1 Download

Updated 04 May 2017

View License

This class stores an extended list of colors by their full name and their corresponding 1x3 RGB (e.g. Red-Green-Blue) arrays in a single container map.
Color Properties:
All this class properties are protected or private to promote object oriented reuse.
Color Methods:

language - returns the language used by the current instance of Color to identify clor keys. Supported languages are english, french, and spanish.

rgb - returns the RGB triplet array of one or more colors identified by their name. If a color does not fit inside the list of supported colors it is simply ignored. When input colors is a cell string each line in the returned RGB matrix corresponds to one color.

list - prints a list of supported colors by this class into the console.

colors - returns the list of supported colors as a cell string.

plot - plots a graphic/chart of all supported colors which could be used to quickly localize a given color name.


(1) list available colors:

(2) plot a chart of all available colors:

(3) get RGB color triplet for 'Maroon:
[RGB,~] = rgb(Color,'Maroon')
0.5020 0 0

(4) get RGB color matrx for colors 'Beige' 'Maroon' 'SeaShell' and 'deep pink' plus one erroneous color name (neglected):
rgb(Color,{'Beige' 'Maroon' 'SeaShell' 'deep pink' 'error'})
ans =
0.9608 0.9608 0.8627
0.5020 0 0
1.0000 0.9608 0.9333
1.0000 0.0784 0.5765

(5) plot the sine function with a 'deep pink' color:
plot(linspace(0,2*pi,100),sin(linspace(0,2*pi,100)), 'color',rgb(Color,'deep pink'));

(6) load a Color object with French color names, get RGB triplet for 'orchidée sombre' color, and plot a chart with French colors:
clr_fr = Color('Language','francais');
rgb(clr_fr,'orchidée sombre')
ans =
0.6000 0.1961 0.8000

(7) load a Color object with Spanish color names, get RGB triplet for 'azul' color, and plot a chart with Spanish colors:
clr_es = Color('Language','espanol');
ans =
0 0 1


[1] 'RGB Color Codes Chart',

[2] 'HTML Color Codes',

[3] 'CSS Color Module Level 3',


1.0 - Released 27/04/2017
Compatible with the RGB Color Codes Chart see reference [1].

2.0 - Released 02/05/2017
Compatible also with HTML/CSS3 color codes (see references [2,3]).
Accepts case insensitive color names so 'darksalmon', 'dark salmon', 'DarkSalmon', 'Dark Salmon' are all equivalent.
Some functions were renamed (i.e. getRGB to rgb, and plotColors changed to plot).

3.0 - Released 03/05/2017
Add French and Spanish languages support.

Comments and Ratings (2)

Adil Sbai

The original submission doesn't indicate used pallette. This was taken from the natural color names as in Version 2.0 supports now the HTML/CSS3 palette names as in But also allows for any combination of upper- and/or lower-case names.

About Stephen's comment: of course 'Maron' is clearly a type error. It should be 'Maroon' as in the source code. No need to be smart to understand that.

What color palette does this class use: CSS, SVG1.0, X11, or something else? This should be documented clearly in the description.

Your example uses 'Maron', but 'Maron' is not an English color name, and the word "Maron" does not exist anywhere in the file. How did you manage to create that example with an incorrect name?

Note to other users: you might like try my FEX submission, which supports many named-color palettes (SVG1.0, CSS, X11, MATLAB, HTML4, xcolor, and more):

My submission will identify input RGB values using appropriate color-difference metrics (CIE94, CIE76, CMCl:c, CIEDE2000, etc). It also matches color names with case and space flexible name recognition: this means it is very intuitive to use but very generous in recognizing names. It also has bonus functions for displaying the palette colors.


Add support for French and Spanish languages.

Compatible with HTML/CSS3 color codes. Accepts case insensitive color names. Some functions were renamed.

Formatting description text

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor