Is there a list of all color long names?

608 ビュー (過去 30 日間)
Monika Jaskolka
Monika Jaskolka 2018 年 1 月 30 日
回答済み: Yasin Zamani 2019 年 5 月 5 日
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:

採用された回答

Walter Roberson
Walter Roberson 2018 年 1 月 30 日
None of those other colors are accepted by MATLAB color specifications.
  8 件のコメント
Monika Jaskolka
Monika Jaskolka 2018 年 1 月 30 日
編集済み: Monika Jaskolka 2018 年 1 月 30 日
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 2018 年 1 月 30 日
編集済み: Walter Roberson 2018 年 1 月 30 日
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.

サインインしてコメントする。

その他の回答 (3 件)

Jan
Jan 2018 年 1 月 30 日
編集済み: Jan 2018 年 1 月 30 日
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 件のコメント
Jan
Jan 2018 年 1 月 30 日
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 2018 年 10 月 3 日
編集済み: Stephen23 2018 年 10 月 5 日
"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:

サインインしてコメントする。


Yasin Zamani
Yasin Zamani 2019 年 5 月 5 日
color (download link) converts color name or hexadecimal color code to an rgb triplet.

Steven Lord
Steven Lord 2018 年 1 月 30 日
"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 件のコメント
Monika Jaskolka
Monika Jaskolka 2018 年 1 月 30 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by