{"id":5546,"date":"2014-09-26T09:00:20","date_gmt":"2014-09-26T13:00:20","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=5546"},"modified":"2014-09-25T08:46:46","modified_gmt":"2014-09-25T12:46:46","slug":"interactively-changing-color-axis","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2014\/09\/26\/interactively-changing-color-axis\/","title":{"rendered":"Interactively changing color axis"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/47604-colormouse\">Colormouse<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/494863\">Patrick<\/a>.\r\n   <\/p>\r\n   <p>In addition to examining the actual values or creating line plots, you can get a lot of insight by visualizing data with color.\r\n      MATLAB has a number of functions that let you represent your data with color, including <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/image.html\"><tt>image<\/tt><\/a>, <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/surf.html\"><tt>surf<\/tt><\/a>, <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/mesh.html\"><tt>mesh<\/tt><\/a>, and <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/contourf.html\"><tt>contourf<\/tt><\/a>. Many of these functions make use of a <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/colormap.html\"><tt>colormap<\/tt><\/a> that represents a range of colors for the values.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">contourf(peaks)\r\ncolorbar<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_colormouse\/potw_colormouse_01.png\"> <p><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/colorbar.html\"><tt>colorbar<\/tt><\/a> above shows the range of colors represented in the figure. You can programmatically change this color range by using the\r\n      <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/caxis.html\"><tt>caxis<\/tt><\/a> function.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">caxis([-4 4])<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_colormouse\/potw_colormouse_02.png\"> <p>Patrick's <tt>colormouse<\/tt> allows you to change the colormap range interactively using the mouse. Calling <tt>colormouse<\/tt> adds a toolbar button to the current figure.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_colormouse\/colormouse_toolbar_screenshot.png\"> <\/p>\r\n   <p>Once you're in colormouse mode, you can click-n-drag to move (by moving the mouse up and down) or widen\/narrow (left and right)\r\n      the color range.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_colormouse\/colormouse_animation.gif\"> <\/p>\r\n   <p>You can also select a specific colormap from a context menu.<\/p>\r\n   <p><b>Comments<\/b><\/p>\r\n   <p>Let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=5546#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/47604-colormouse#comments\">comment<\/a> for Patrick.\r\n   <\/p>\r\n   <p><i>Note that the actual sourcecode resides on GitHub, so please check the GitHub page for the license information.<\/i><\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_c2a010a7f7c4452d88ae1b59e033191e() {\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='c2a010a7f7c4452d88ae1b59e033191e ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' c2a010a7f7c4452d88ae1b59e033191e';\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 = '';\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 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_c2a010a7f7c4452d88ae1b59e033191e()\"><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; R2014a<br><\/p>\r\n<\/div>\r\n<!--\r\nc2a010a7f7c4452d88ae1b59e033191e ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\r\n% Jiro>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/47604-colormouse Colormouse>\r\n% by <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/494863\r\n% Patrick>.\r\n%\r\n% In addition to examining the actual values or creating line plots, you\r\n% can get a lot of insight by visualizing data with color. MATLAB has a\r\n% number of functions that let you represent your data with color,\r\n% including <https:\/\/www.mathworks.com\/help\/matlab\/ref\/image.html |image|>,\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/surf.html |surf|>,\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/mesh.html |mesh|>, and\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/contourf.html |contourf|>. Many\r\n% of these functions make use of a\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/colormap.html |colormap|> that\r\n% represents a range of colors for the values.\r\n\r\ncontourf(peaks)\r\ncolorbar\r\n\r\n%%\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/colorbar.html |colorbar|> above\r\n% shows the range of colors represented in the figure. You can\r\n% programmatically change this color range by using the\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/caxis.html |caxis|> function.\r\n\r\ncaxis([-4 4])\r\n\r\n%%\r\n% Patrick's |colormouse| allows you to change the colormap range\r\n% interactively using the mouse. Calling |colormouse| adds a toolbar button\r\n% to the current figure.\r\n%\r\n% <<colormouse_toolbar_screenshot.png>>\r\n%\r\n% Once you're in colormouse mode, you can click-n-drag to move (by moving\r\n% the mouse up and down) or widen\/narrow (left and right) the color range.\r\n%\r\n% <<colormouse_animation.gif>>\r\n%\r\n% You can also select a specific colormap from a context menu.\r\n%\r\n% *Comments*\r\n%\r\n% Let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=5546#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/47604-colormouse#comments\r\n% comment> for Patrick.\r\n%\r\n% _Note that the actual sourcecode resides on GitHub, so please check the\r\n% GitHub page for the license information._\r\n\r\n##### SOURCE END ##### c2a010a7f7c4452d88ae1b59e033191e\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_colormouse\/potw_colormouse_01.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n   Jiro's pick this week is Colormouse by Patrick.\r\n   \r\n   In addition to examining the actual values or creating line plots, you can get a lot of insight by visualizing data with color.\r\n     ... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2014\/09\/26\/interactively-changing-color-axis\/\">read more >><\/a><\/p>","protected":false},"author":35,"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\/5546"}],"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\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=5546"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5546\/revisions"}],"predecessor-version":[{"id":5549,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5546\/revisions\/5549"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=5546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=5546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=5546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}