{"id":1181,"date":"2014-10-13T16:12:12","date_gmt":"2014-10-13T20:12:12","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/?p=1181"},"modified":"2019-11-01T11:22:50","modified_gmt":"2019-11-01T15:22:50","slug":"a-new-colormap-for-matlab-part-1-introduction","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2014\/10\/13\/a-new-colormap-for-matlab-part-1-introduction\/","title":{"rendered":"A New Colormap for MATLAB &#8211; Part 1 &#8211; Introduction"},"content":{"rendered":"<div class=\"content\"><p>I believe it was almost four years ago that we started kicking around the idea of changing the default colormap in MATLAB. Now, with the major update of the MATLAB graphics system in R2014b, the colormap change has finally happened. Today I'd like to introduce you to parula, the new default MATLAB colormap:<\/p><pre class=\"codeinput\">showColormap(<span class=\"string\">'parula'<\/span>,<span class=\"string\">'bar'<\/span>)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2014\/parula_part_1_01.png\" alt=\"\"> <p>(Note: I will make <tt>showColormap<\/tt> and other functions used below available on MATLAB Central File Exchange soon.)<\/p><p>I'm going spend the next several weeks writing about this change. In particular, I plan to discuss why we made this change and how we settled on parula as the new default.<\/p><p>To get started, I want to show you some visualizations using jet, the previous colormap, and ask you some questions about them.<\/p><p><b>Question 1:<\/b> In the chart below, as you move from left to right along the line shown in yellow, how does the data change? Does it trend higher? Or lower? Or does it trend higher in some places and lower in others?<\/p><pre class=\"codeinput\">fluidJet\r\nhold <span class=\"string\">on<\/span>\r\nplot([100 160],[100 135],<span class=\"string\">'y'<\/span>,<span class=\"string\">'LineWidth'<\/span>,3)\r\nhold <span class=\"string\">off<\/span>\r\ncolormap(gca,<span class=\"string\">'jet'<\/span>)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2014\/parula_part_1_02.png\" alt=\"\"> <p><b>Question 2:<\/b> In the filled contour plot below, which regions are high and which regions are low?<\/p><pre class=\"codeinput\">filledContour15\r\ncolormap(gca,rgb2gray(jet))\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2014\/parula_part_1_03.png\" alt=\"\"> <p>The next questions relate to the three plots below (A, B, and C) showing different horizontal oscillations.<\/p><p><b>Question 3:<\/b> Which horizontal oscillation (A, B, or C) has the highest amplitude?<\/p><p><b>Question 4:<\/b> Which horizontal oscillation (A, B, or C) is closest to a pure sinusoid?<\/p><p><b>Question 5:<\/b> In comparing plots A and C, which one starts high and goes low, and which one starts low and goes high?<\/p><pre class=\"codeinput\">subplot(2,2,1)\r\nhorizontalOscillation1\r\ntitle(<span class=\"string\">'A'<\/span>)\r\n\r\nsubplot(2,2,2)\r\nhorizontalOscillation2\r\ntitle(<span class=\"string\">'B'<\/span>)\r\n\r\nsubplot(2,2,3)\r\nhorizontalOscillation3\r\ntitle(<span class=\"string\">'C'<\/span>)\r\n\r\ncolormap(jet)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2014\/parula_part_1_04.png\" alt=\"\"> <p>Next time I'll answer the questions above as a way to launch into consideration of the strengths and weaknesses of jet, the previous default colormap. Then, over the next few weeks, I'll explore issues in using color for data visualization, colormap construction principles, use of the L*a*b* color space, and quantitative and qualitative comparisons of parula and jet. Toward the end, I'll even discuss how the unusual name for the new colormap came about. I've created a new blog category (<a href=\"https:\/\/blogs.mathworks.com\/steve\/category\/colormap\">colormap<\/a>) to gather the posts together in a series.<\/p><p>If you want a preview of some of the issues I'll be discussing, take a look at the technical paper <a href=\"https:\/\/www.mathworks.com\/content\/dam\/mathworks\/tag-team\/Objects\/r\/81137_92238v00_RainbowColorMap_57312.pdf\">\"Rainbow Color Map Critiques: An Overview and Annotated Bibliography.\"<\/a> It was published on mathworks.com just last week.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_2f55117d1f744aa388f4adf03d0c985f() {\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='2f55117d1f744aa388f4adf03d0c985f ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 2f55117d1f744aa388f4adf03d0c985f';\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        copyright = 'Copyright 2014 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 copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\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     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_2f55117d1f744aa388f4adf03d0c985f()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2014b<br><\/p><\/div><!--\r\n2f55117d1f744aa388f4adf03d0c985f ##### SOURCE BEGIN #####\r\n%%\r\n% I believe it was almost four years ago that we started kicking around the idea\r\n% of changing the default colormap in MATLAB. Now, with the major update of the\r\n% MATLAB graphics system in R2014b, the colormap change has finally happened.\r\n% Today I'd like to introduce you to parula, the new default MATLAB colormap: \r\n\r\nshowColormap('parula','bar')\r\n\r\n%%\r\n% (Note: I will make |showColormap| and others functions used below available on\r\n% MATLAB Central File Exchange soon.)\r\n%\r\n% I'm going spend the next several weeks writing about this change. In\r\n% particular, I plan to discuss why we made this change and how we settled on\r\n% parula as the new default.\r\n%\r\n% To get started, I want to show you some visualizations using jet, the previous\r\n% colormap, and ask you some questions about them.\r\n%%\r\n% *Question 1:* In the chart below, as you move from left to right along the\r\n% line shown in yellow, how does the data change? Does it trend higher? Or lower?\r\n% Or does it trend higher in some places and lower in others?\r\n\r\nfluidJet\r\nhold on\r\nplot([100 160],[100 135],'y','LineWidth',3)\r\nhold off\r\ncolormap(gca,'jet')\r\n\r\n%%\r\n% *Question 2:* In the filled contour plot below, which regions are high and\r\n% which regions are low?\r\n\r\nfilledContour15\r\ncolormap(gca,rgb2gray(jet))\r\n\r\n%%\r\n% The next questions relate to the three plots below (A, B, and C) showing\r\n% different horizontal oscillations.\r\n%\r\n% *Question 3:* Which horizontal oscillation (A, B, or C) has the highest\r\n% amplitude?\r\n%\r\n% *Question 4:* Which horizontal oscillation (A, B, or C) is closest to a pure\r\n% sinusoid?\r\n%\r\n% *Question 5:* In comparing plots A and C, which one starts high and goes low,\r\n% and which one starts low and goes high?\r\n\r\nsubplot(2,2,1)\r\nhorizontalOscillation1\r\ntitle('A')\r\n\r\nsubplot(2,2,2)\r\nhorizontalOscillation2\r\ntitle('B')\r\n\r\nsubplot(2,2,3)\r\nhorizontalOscillation3\r\ntitle('C')\r\n\r\ncolormap(jet)\r\n\r\n%%\r\n% Next time I'll answer the questions above as a way to launch into\r\n% consideration of the strengths and weaknesses of jet, the previous default\r\n% colormap. Then, over the next few weeks, I'll explore issues in using color\r\n% for data visualization, colormap construction principles, use of the L*a*b*\r\n% color space, and quantitative and qualitative comparisons of parula and jet.\r\n% Toward the end, I'll even discuss how the unusual name for the new colormap\r\n% came about. I've created a new blog category \r\n% (<https:\/\/blogs.mathworks.com\/steve\/category\/colormap colormap>) to gather the posts\r\n% together in a series.\r\n%\r\n% If you want a preview of some of the issues I'll be discussing, take a look at\r\n% the technical paper\r\n% <https:\/\/www.mathworks.com\/tagteam\/81137_92238v00_RainbowColorMap_57312.pdf\r\n% \"Rainbow Color Map Critiques: An Overview and Annotated Bibliography.\"> It\r\n% was published on mathworks.com just last week.\r\n\r\n##### SOURCE END ##### 2f55117d1f744aa388f4adf03d0c985f\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2014\/parula_part_1_04.png\" onError=\"this.style.display ='none';\" \/><\/div><p>I believe it was almost four years ago that we started kicking around the idea of changing the default colormap in MATLAB. Now, with the major update of the MATLAB graphics system in R2014b, the... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2014\/10\/13\/a-new-colormap-for-matlab-part-1-introduction\/\">read more >><\/a><\/p>","protected":false},"author":42,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[24],"tags":[58,80,90,68,104,72,52],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/1181"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/comments?post=1181"}],"version-history":[{"count":8,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/1181\/revisions"}],"predecessor-version":[{"id":2491,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/1181\/revisions\/2491"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=1181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=1181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=1181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}