File Exchange Pick of the Week

Our best user submissions

Convert between RGB and Color Names 2

Posted by Will Campbell,

Will‘s pick this week is Convert between RGB and Color Names by Stephen Cobeldick.

A fairly common challenge I encounter is the need for more plot colors. I have too many lines on my plot, and MATLAB begins to cycle back through colors it has already used. There are plenty of coping mechanisms for the situation. When I’ve cobbled my own solution together in the past, I always encounter a related challenge of deciding what extra colors to add. I’ve often found myself on a website toying with RGB values till I settle on one I like.

Stephen’s submission provides an easy way to use determine an RGB combination based on a recognizable name. You choose from one of 28 palettes, each of which contain a lexicon of color names to choose from. I went with xkcd, which contains 949 preconfigured colors, everything from “Yellowy Green” to “Yellow/Green” to “Yellowish Green.” (There are some non-yellow/green ones too). Want to know what they look like, call COLORNAMES_VIEW to get a figure window browser:


xkcd Colornames View

Once you have a color that speaks to you, you can call COLORNAMES to get the RGB vector that corresponds to it. I flipped the output arguments around so that I could inline a call directly in a plot command. Turns out this is what a sine wave of dried blood looks like:

Dried Blood Line

One fact that really impressed me is that Stephen continues to support this submission more than 4 years after he first uploaded it. Just last month, he tweaked it for R2018b compatibility. Major kudos for maintaining your work!

Two minor suggestions I would offer for the next update. One would be to include support for strings in addition to character arrays. And also consider adding Sherwin-Williams as a palette. Nothing will be more amusing than to plot with Brainstorm Bronze or Bungalow Beige.

Let us know what you think here or leave a comment for Stephen.

Note

Comments are closed.

2 CommentsOldest to Newest

Stephen Cobeldick replied on : 1 of 2
@Will Campbell: thank you for selecting COLORNAMES for PotW this week. This submission grew out of another project involving colorspace conversions: as an experiment I wanted to create a reasonably robust color-naming algorithm using standard deltaE metrics (something that was also missing on FEX). After that I added some flexible name matching code, and voilà! Actually one of the hardest parts has been collecting the different palettes' data together, and I very much appreciate tips for new palettes to include: you can expect to see Sherwin-Williams some time in the future... "I always encounter a related challenge of deciding what extra colors to add..." Another tool which is better suited to that task: https://www.mathworks.com/matlabcentral/fileexchange/70215-maximally-distinct-color-generator Use the "exc" option to specify the existing colors, and it will identify new colors that are most distant from them.
Yvon replied on : 2 of 2
Once again, THANK YOU for your page! to convert CMYK HTML RGB PANTONE or RAL I like this page https://www.decoenligne.org/conversions-couleurs/