{"id":10699,"date":"2019-04-26T09:00:20","date_gmt":"2019-04-26T13:00:20","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=10699"},"modified":"2019-04-25T21:16:12","modified_gmt":"2019-04-26T01:16:12","slug":"convert-between-rgb-and-color-names","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2019\/04\/26\/convert-between-rgb-and-color-names\/","title":{"rendered":"Convert between RGB and Color Names"},"content":{"rendered":"<p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/76890\">Will<\/a>&#8216;s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/48155-convert-between-rgb-and-color-names\">Convert between RGB and Color Names<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3102170-stephen-cobeldick\">Stephen Cobeldick<\/a>.<\/p>\n<p>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&#8217;ve cobbled my own solution together in the past, I always encounter a related challenge of deciding what extra colors to add. I&#8217;ve often found myself on a website toying with RGB values till I settle on one I like.<\/p>\n<p>Stephen&#8217;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 &#8220;Yellowy Green&#8221; to &#8220;Yellow\/Green&#8221; to &#8220;Yellowish Green.&#8221; (There are some non-yellow\/green ones too). Want to know what they look like, call COLORNAMES_VIEW to get a figure window browser:<br \/>\n<center><br \/>\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/will_campbell\/potw_colornames\/colornames_view.png\" alt=\"xkcd Colornames View\" \/><\/center><br \/>\nOnce 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:<br \/>\n<center><br \/>\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/will_campbell\/potw_colornames\/colornames_plot.png\" alt=\"Dried Blood Line\" \/><\/center><br \/>\nOne 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! <\/p>\n<p>Two minor suggestions I would offer for the next update. One would be to include support for <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/string.html\">strings<\/a> in addition to character arrays. And also consider adding <a href=\"https:\/\/images.sherwin-williams.com\/content_images\/sw-pdf-sherwin-williams-color.pdf\">Sherwin-Williams<\/a> as a palette. Nothing will be more amusing than to plot with Brainstorm Bronze or Bungalow Beige.<\/p>\n<p>Let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=10699#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/48155-convert-between-rgb-and-color-names#comments\">comment<\/a> for Stephen.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/will_campbell\/potw_colornames\/colornames_view.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>Will&#8216;s pick this week is Convert between RGB and Color Names by Stephen Cobeldick.<br \/>\nA fairly common challenge I encounter is the need for more plot colors. I have too many lines on my plot, and&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2019\/04\/26\/convert-between-rgb-and-color-names\/\">read more >><\/a><\/p>\n","protected":false},"author":45,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10699"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=10699"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10699\/revisions"}],"predecessor-version":[{"id":10709,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10699\/revisions\/10709"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=10699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=10699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=10699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}