Is there a list of all color long names?

594 Ansichten (letzte 30 Tage)
Monika Jaskolka
Monika Jaskolka am 30 Jan. 2018
Beantwortet: Yasin Zamani am 5 Mai 2019
Information on Matlab's color specification describes 8 basic colors and states that, "... long names are character vectors that specify one of eight predefined colors." https://www.mathworks.com/help/matlab/ref/colorspec.html
However, there are other long names available: lightblue, darkblue, darkgreen, purple, orange, gray, etc. Is there a comprehensive list of all available color names?
Edit: I am using the colors with Simulink, specifically to set the ForegroundColor and BackgroundColor parameters of blocks with set_param(). It is also possible to do this manually via the Context Menu, where some of the colors are listed. Purple and darkblue are not listed in the menu, but are valid colors:

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 30 Jan. 2018
None of those other colors are accepted by MATLAB color specifications.
  8 Kommentare
Monika Jaskolka
Monika Jaskolka am 30 Jan. 2018
Bearbeitet: Monika Jaskolka am 30 Jan. 2018
Thanks for looking into this. I checked color names from LaTeX, HTML, and Wikipedia (A-F, G-M, N-Z). Combining your lists with mine, the colors which work as Simulink block ForegroundColor/ BackgroundColor values in 2017b are:
Black
Blue
BlueViolet
Brown
Cyan
DarkBlue
DarkGreen
DarkMagenta
DarkSalmon
DarkYellow
Gray
Green
LightBlue
LightSeaGreen
Magenta
Orange
PaleYellow
Purple
Red
SmahtGuide
White
Yellow
Teal did not work for me.
Walter Roberson
Walter Roberson am 30 Jan. 2018
Bearbeitet: Walter Roberson am 30 Jan. 2018
teal worked for me, for a Simulink.Annotation object . Might be a version difference.
'auto' is also accepted.
I was not able to scrape anything else.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

Jan
Jan am 30 Jan. 2018
Bearbeitet: Jan am 30 Jan. 2018
While I do not know the list of names defined in Matlab, you can find tools for getting the RGB values for color names in the FileExchange:
This seems to be an interesting problem for the FileExchange, like progressbars and recursive dir commands.
If you are looking for the color names recognized my Matlab directly, you have to search in the documentation:
docsearch darkgreen
I found a hint, that the LaTeX colors are meant. Then https://en.wikibooks.org/wiki/LaTeX/Colors should work.
In theory we could check the code of Matlab for a list of defined color names, but this would be reverse engineering, which is forbidden by the license conditions.
  3 Kommentare
Jan
Jan am 30 Jan. 2018
If it is not documented, you cannot be sure, if it is backward and forward compatible. I've suggested the tool from the FileExchange to convert a known list of color names to RGB values, which work with all Matlab versions for sure. You can insert the results in the field for selecting a "Custom" color.
Stephen23
Stephen23 am 3 Okt. 2018
Bearbeitet: Stephen23 am 5 Okt. 2018
"This seems to be an interesting problem for the FileExchange, like progressbars and recursive dir commands."
And of course writing a simple cell array of such names is trivially easy (and that is all some of those submissions are). However anyone wanting to write more than just a simple "cell array of names", e.g. by matching closest RGB colors to get the colornames, will be confronted with a challenge: how to define what the closest colors means mathematically... and they will find that there are standard metrics that define the perceptual differences between colors:
Each of those metrics behaves differently, depending on the colors and the "distances" involved. There is no perfect metric, but some are definitely better than others. Most FEX submissions do not even bother, and just rely on comparing RGB (ouch!).
"I found a hint, that the LaTeX colors are meant..."
Neither TeX nor LaTeX define any colors, but the commonly used packages color and xcolor certainly do. You will also find xcolor fully supported in my FEX submission, together with the named MATLAB colors, dvips colors, X11 colors, CSS colors, and many others:

Melden Sie sich an, um zu kommentieren.


Yasin Zamani
Yasin Zamani am 5 Mai 2019
color (download link) converts color name or hexadecimal color code to an rgb triplet.

Steven Lord
Steven Lord am 30 Jan. 2018
"However, there are other long names available: lightblue, darkblue, darkgreen, purple, orange, gray, etc. "
How are you using those 'other long names'? Did you perhaps download an add-on that defines functions by those names to return an RGB value? You can check that using the which function. gray is a function that returns a colormap matrix, but I don't believe the others exist.
>> plot(1:10, 1:10, 'Color' ,'lightblue')
Error using plot
Specified character vector is an invalid color value.
You can define a variable or a function named lightblue and then use it, but I wouldn't call that an "available color name".
lightblue = [0.8 0.8 1];
plot(1:10, 1:10, 'Color', lightblue)
  1 Kommentar
Monika Jaskolka
Monika Jaskolka am 30 Jan. 2018
Sorry I didn't mention how I am using these colors originally. I have updated the original question with this info.
I am using the colors with Simulink as values for the ForegroundColor and BackgroundColor parameters of blocks. Using which on these colors does not find them.

Melden Sie sich an, um zu kommentieren.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by