Is there a list of all color long names?
594 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Monika Jaskolka
le 30 Jan 2018
Réponse apportée : Yasin Zamani
le 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:
0 commentaires
Réponse acceptée
Walter Roberson
le 30 Jan 2018
None of those other colors are accepted by MATLAB color specifications.
There are a number of lists. My favorite is https://blog.xkcd.com/2010/05/03/color-survey-results/ but see also https://en.wikipedia.org/wiki/List_of_colors:_A%E2%80%93F
8 commentaires
Monika Jaskolka
le 30 Jan 2018
Modifié(e) : Monika Jaskolka
le 30 Jan 2018
Walter Roberson
le 30 Jan 2018
Modifié(e) : Walter Roberson
le 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.
Plus de réponses (3)
Jan
le 30 Jan 2018
Modifié(e) : Jan
le 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:
- https://www.mathworks.com/matlabcentral/fileexchange/24497-rgb-triple-of-color-name--version-2
- https://www.mathworks.com/matlabcentral/fileexchange/12326-color-name-identification--fuzzycolor
- https://www.mathworks.com/matlabcentral/fileexchange/56006-colors-name-
- https://www.mathworks.com/matlabcentral/fileexchange/48155-convert-between-rgb-and-color-names
- https://www.mathworks.com/matlabcentral/fileexchange/46872-intuitive-rgb-color-values-from-xkcd . See also https://xkcd.com/color/rgb/
- https://www.mathworks.com/matlabcentral/fileexchange/22939-gnu-emacs-color-matrix
- https://www.mathworks.com/matlabcentral/fileexchange/1805-rgb-m
- https://www.mathworks.com/matlabcentral/fileexchange/22325-rgb2name
- https://www.mathworks.com/matlabcentral/fileexchange/63871-get-a-color-from-a-large-color-list
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 commentaires
Jan
le 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
le 3 Oct 2018
Modifié(e) : Stephen23
le 5 Oct 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:
Steven Lord
le 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)
Voir également
Catégories
En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!