{"id":2513,"date":"2010-01-08T14:18:36","date_gmt":"2010-01-08T14:18:36","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2010\/01\/08\/lutbar-a-colormap-tool-to-make-your-life-easier\/"},"modified":"2010-01-08T14:18:36","modified_gmt":"2010-01-08T14:18:36","slug":"lutbar-a-colormap-tool-to-make-your-life-easier","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2010\/01\/08\/lutbar-a-colormap-tool-to-make-your-life-easier\/","title":{"rendered":"LUTBAR: A colormap tool to make your life easier"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction><\/introduction>\r\n   <p>I don't know how many times I've spun my wheels, trying to determine the best colormap for a graphic I was working on, and\r\n      cycling one-by-one through the built-in colormaps in MATLAB. MATLAB has many <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009b\/techdoc\/ref\/colormap.html\">pre-defined colormaps<\/a>, and selecting the best one can be a tedious process. At least, it <i>was<\/i> a tedious process. <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/4309\">Us<\/a>'s <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/9137-lutbar--a-pedestrian-colormap-toolbar-contextmenu-creator\">LUTBAR<\/a> tool streamlines the process by creating a toolbar of available colormaps; clicking on any entry automatically updates the\r\n      figure's colorbar and allows you to see your figure in a variety of different colors. Better yet, LUTBAR automatically includes\r\n      built-in colormaps, and enables you to include custom colormaps as well.\r\n   <\/p>\r\n   <p>Let's say, for instance that you had this bit of code:<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">figure(<span style=\"color: #A020F0\">'color'<\/span>,<span style=\"color: #A020F0\">'w'<\/span>);\r\nL = 40 * membrane(1,25);\r\nx = -1:1\/25:1;\r\ns = surf(x,x',L,<span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'edgecolor'<\/span>,<span style=\"color: #A020F0\">'none'<\/span>,<span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'FaceLighting'<\/span>,<span style=\"color: #A020F0\">'phong'<\/span>, <span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'AmbientStrength'<\/span>,0.3, <span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'DiffuseStrength'<\/span>,0.6, <span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'Clipping'<\/span>,<span style=\"color: #A020F0\">'off'<\/span>,<span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'BackFaceLighting'<\/span>,<span style=\"color: #A020F0\">'lit'<\/span>, <span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'SpecularStrength'<\/span>,1.1, <span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'SpecularColorReflectance'<\/span>,1, <span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'SpecularExponent'<\/span>,7);\r\nset(gca,<span style=\"color: #A020F0\">'visible'<\/span>,<span style=\"color: #A020F0\">'off'<\/span>)\r\nlight(<span style=\"color: #A020F0\">'Position'<\/span>,[40 100 20], <span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'Style'<\/span>,<span style=\"color: #A020F0\">'local'<\/span>, <span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'Color'<\/span>,[0 0.8 0.8]);\r\nlight(<span style=\"color: #A020F0\">'Position'<\/span>,[.5 -1 .4], <span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'Color'<\/span>,[0.8 0.8 0]);<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/..\/images\/pick\/lutbar1.png\"> <\/p>\r\n   <p>Most of you will probably recognize the L-shaped membrane; it plays an interesting and important role at The MathWorks.(For\r\n      the back story on our logo, check out <a href=\"https:\/\/www.mathworks.com\/company\/aboutus\/founders\/clevemoler.html\">Cleve's \"History of MATLAB\" video<\/a>; it's just over 8 minutes, and well worth a watch!)\r\n   <\/p>\r\n   <p>But you will also undoubtedly recognize that the coloring is \"wrong.\" I could cycle manually (or even automatically) through\r\n      the built-in colormaps:\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">mapOpts = {<span style=\"color: #A020F0\">'autumn'<\/span>,<span style=\"color: #A020F0\">'bone'<\/span>,<span style=\"color: #A020F0\">'colorcube'<\/span>,<span style=\"color: #A020F0\">'cool'<\/span>,<span style=\"color: #0000FF\">...<\/span>\r\n           <span style=\"color: #A020F0\">'copper'<\/span>,<span style=\"color: #A020F0\">'flag'<\/span>,<span style=\"color: #A020F0\">'gray'<\/span>,<span style=\"color: #A020F0\">'hot'<\/span>,<span style=\"color: #A020F0\">'hsv'<\/span>,<span style=\"color: #0000FF\">...<\/span>\r\n           <span style=\"color: #A020F0\">'jet'<\/span>,<span style=\"color: #A020F0\">'lines'<\/span>,<span style=\"color: #A020F0\">'pink'<\/span>,<span style=\"color: #A020F0\">'prism'<\/span>,<span style=\"color: #A020F0\">'spring'<\/span>,<span style=\"color: #0000FF\">...<\/span>\r\n           <span style=\"color: #A020F0\">'summer'<\/span>,<span style=\"color: #A020F0\">'white'<\/span>,<span style=\"color: #A020F0\">'winter'<\/span>};\r\n<span style=\"color: #0000FF\">for<\/span> ii = 1:numel(mapOpts)\r\n    set(gcf,<span style=\"color: #A020F0\">'colormap'<\/span>,eval(mapOpts{ii}));\r\n    pause(0.5);\r\n<span style=\"color: #0000FF\">end<\/span>\r\n\r\n<\/pre>\r\n<p><p>\r\n\r\n<embed src=\"https:\/\/blogs.mathworks.com\/pick\/..\/images\/pick\/lutbarcamrec.swf\"\r\nwidth=\"500\" height=\"325\">\r\n<\/embed>\r\n\r\n<\/p>\r\n\r\n   <p>Us gives us a cleaner, easier approach. All one has to do is issue the <tt>lutbar<\/tt> command:\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">lutbar<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/..\/images\/pick\/lutbarscreenshot.png \"width=\"500\" height=\"350\"> <p><\/p>\r\n   <p>We now see a toolbar of selectable colormaps; clicking on any individual colormap icon updates the visualization. If you look with a careful eye,\r\n      you might notice a separation line on the toolbar to the right of the (blue-to-green) 'winter' map. That line delimits the\r\n      end of the built-in maps, and the beginning of a collection of user-defined maps. In fact, the last colormap on the toolbar\r\n      is really just a uniform red colormap of my creation. Applying it yields the MathWorks logo we all know and love.\r\n   <\/p>\r\n   <p>(Did you know that The MathWorks logo was uniformly colored, and that the apparent color gradations were created purely by\r\n      <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009b\/techdoc\/visualize\/f1-21767.html\">manipulating the lighting<\/a>?)\r\n   <\/p>\r\n   <p>Us's code is beautifully implemented and documented; we've come to expect nothing less from him. Thanks for sharing this great\r\n      function!\r\n   <\/p>\r\n   <p><a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2513#respond\">Comments?<\/a><\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_49e0c35a5665482a8262de611128395c() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='49e0c35a5665482a8262de611128395c ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 49e0c35a5665482a8262de611128395c';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Brett Shoelson';\r\n        copyright = 'Copyright 2010 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_49e0c35a5665482a8262de611128395c()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.10<br><\/p>\r\n<\/div>\r\n<!--\r\n49e0c35a5665482a8262de611128395c ##### SOURCE BEGIN #####\r\n%% LUTBAR: A colormap tool to make your life easier\r\n%% \r\n% I don't know how many times I've spun my wheels, trying to determine the\r\n% best colormap for a graphic I was working on, and cycling one-by-one\r\n% through the built-in colormaps in MATLAB. MATLAB has many \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2009b\/techdoc\/ref\/colormap.html pre-defined colormaps>,\r\n% and selecting the best one can be a tedious process. At least, it _was_ a tedious process.\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/4309 Us>'s  \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/9137-lutbar--a-pedestrian-colormap-toolbar-contextmenu-creator LUTBAR> tool\r\n% streamlines the process by creating a toolbar of available colorbars; clicking on any entry automatically updates the \r\n% figure's colorbar and allows you to see your figure in a variety of\r\n% different colors. Better yet, LUTBAR automatically includes built-in\r\n% colormaps, and enables you to include custom colormaps as well.\r\n\r\n%%\r\n% Let's say, for instance that you had this bit of code:\r\nfigure('color','w');\r\nL = 40 * membrane(1,25);\r\nx = -1:1\/25:1;\r\ns = surf(x,x',L,...\r\n    'edgecolor','none',...\r\n    'FaceLighting','phong', ...\r\n    'AmbientStrength',0.3, ...\r\n    'DiffuseStrength',0.6, ...\r\n    'Clipping','off',...\r\n    'BackFaceLighting','lit', ...\r\n    'SpecularStrength',1.1, ...\r\n    'SpecularColorReflectance',1, ...\r\n    'SpecularExponent',7);\r\nset(gca,'visible','off')\r\nlight('Position',[40 100 20], ...\r\n    'Style','local', ...\r\n    'Color',[0 0.8 0.8]);\r\nlight('Position',[.5 -1 .4], ...\r\n    'Color',[0.8 0.8 0]);\r\n\r\n%%\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/pick\/..\/images\/pick\/lutbar1.png>>\r\n%\r\n\r\n%%\r\n% Most of you will probably recognize the L-shaped membrane; it plays an interesting and important role at The MathWorks.(For the\r\n% back story on our logo, check out \r\n% <https:\/\/www.mathworks.com\/company\/aboutus\/founders\/clevemoler.html Cleve's \"History of MATLAB\" video>; it's just over 8 minutes, and well worth a\r\n% watch!)\r\n\r\n%%\r\n% But you will also undoubtedly recognize that the coloring is \"wrong.\" I\r\n% could cycle manually (or even automatically) through the built-in colormaps:\r\nmapOpts = {'autumn','bone','colorcube','cool',...\r\n           'copper','flag','gray','hot','hsv',...\r\n           'jet','lines','pink','prism','spring',...\r\n           'summer','white','winter'};\r\nfor ii = 1:numel(mapOpts)\r\n    set(gcf,'colormap',eval(mapOpts{ii}));\r\n    pause(0.15);\r\nend\r\n\r\n%%\r\n% \r\n% <<https:\/\/blogs.mathworks.com\/pick\/..\/images\/pick\/lutbarcamtasia.swf>>\r\n% \r\n\r\n%% \r\n% Us gives us a cleaner, easier approach. All one has to do is issue the\r\n% |lutbar| command:\r\n\r\n%%\r\nlutbar\r\n\r\n%%\r\n% \r\n% <<LUTBARScreenShot.png>>\r\n% \r\n\r\n%%\r\n% We now see a toolbar of selectable colormaps; clicking on them updates\r\n% the visualization. If you look with a careful eye, you might notice a\r\n% separation line on the toolbar to the right of the (blue-to-green)\r\n% 'winter' map. That line demarks the end of the built-in maps, and the\r\n% beginning of a collection of user-defined maps. In fact, the last\r\n% colormap on the toolbox is really just a uniform red. Applying it yields\r\n% the MathWorks logo we all know and love.\r\n\r\n%% \r\n% (Did you know that The MathWorks logo was uniformly colored, and that the\r\n% apparent color gradations were created purely by \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2009b\/techdoc\/visualize\/f1-21767.html manipulating the lighting>?)\r\n\r\n%%\r\n% Us's code is beautifully implemented and documented; we've come to expect\r\n% nothing less from him. Thanks for sharing this great function!\r\n\r\n%%\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2502#respond Comments?>\r\n##### SOURCE END ##### 49e0c35a5665482a8262de611128395c\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n   I don't know how many times I've spun my wheels, trying to determine the best colormap for a graphic I was working on, and\r\n      cycling one-by-one through the built-in colormaps in... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2010\/01\/08\/lutbar-a-colormap-tool-to-make-your-life-easier\/\">read more >><\/a><\/p>","protected":false},"author":34,"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\/2513"}],"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\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2513"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2513\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}