{"id":665,"date":"2013-03-27T14:42:07","date_gmt":"2013-03-27T19:42:07","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/?p=665"},"modified":"2013-07-09T07:51:08","modified_gmt":"2013-07-09T12:51:08","slug":"multiple-y-axes","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2013\/03\/27\/multiple-y-axes\/","title":{"rendered":"Multiple Y Axes"},"content":{"rendered":"<div class=\"content\"><!--introduction--><p>We were musing here about how common it is to want more than two Y axes on a plot.  Checking out the File Exchange, there seem to be several candidates, indicating that this is something at least some people find useful.<\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#708b44b8-5fb8-446f-92c3-5a7356e4ab5d\">Sample Plot<\/a><\/li><li><a href=\"#3b58211f-2b7e-484d-952e-5e8fffa5f81c\">List of Some Possibilities<\/a><\/li><li><a href=\"#8c4f04ed-9976-4594-92c5-c77284c345fe\">What are You Plotting with More Y Axes?<\/a><\/li><\/ul><\/div><h4>Sample Plot<a name=\"708b44b8-5fb8-446f-92c3-5a7356e4ab5d\"><\/a><\/h4><p>Here's a sample plot using <tt>plotyy<\/tt> that comes with MATLAB.<\/p><pre class=\"codeinput\">x = 0:0.01:20;\r\ny1 = 200*exp(-0.05*x).*sin(x);\r\ny2 = 0.8*exp(-0.5*x).*sin(10*x);\r\nplotyy(x,y1,x,y2,<span class=\"string\">'plot'<\/span>);\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2013\/plotyyFEX_01.png\" alt=\"\"> <h4>List of Some Possibilities<a name=\"3b58211f-2b7e-484d-952e-5e8fffa5f81c\"><\/a><\/h4><p>In addition to <tt>plotyy<\/tt> in MATLAB, here's a list of <i>some<\/i> of the candidates from the File Exchange.<\/p><div><ul><li><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/9016-addaxis\"> <tt>addaxis<\/tt><\/a><\/li><li><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/4425-ploty4-m\"><tt>plot4y<\/tt><\/a><\/li><li><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/26550-myplotyy\"><tt>Myplotyy<\/tt><\/a><\/li><li><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/1017-plotyyy\"><tt>plotyyy<\/tt><\/a><\/li><li><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/10242-plots-m--plotses-m\"><tt>plots.m plotses.m<\/tt><\/a><\/li><li><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/39595-multiplotyyy\"><tt>multiplotyyy<\/tt><\/a><\/li><\/ul><\/div><h4>What are You Plotting with More Y Axes?<a name=\"8c4f04ed-9976-4594-92c5-c77284c345fe\"><\/a><\/h4><p>I am curious to know what kind of data or results you are plotting so that having multiple y-axes makes a compelling presentation.  Let us know <a href=\"https:\/\/blogs.mathworks.com\/loren\/?p=665#respond\">here<\/a>.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_79a95834e135447399e4a186bba57f16() {\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='79a95834e135447399e4a186bba57f16 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 79a95834e135447399e4a186bba57f16';\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 2013 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_79a95834e135447399e4a186bba57f16()\"><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; R2013a<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2013a<br><\/p><\/div><!--\r\n79a95834e135447399e4a186bba57f16 ##### SOURCE BEGIN #####\r\n%% Multiple Y Axes\r\n% We were musing here about how common it is to want more than two Y axes\r\n% on a plot.  Checking out the File Exchange, there seem to be several\r\n% candidates, indicating that this is something at least some people find\r\n% useful.\r\n\r\n%% Sample Plot\r\n% Here's a sample plot using |plotyy| that comes with MATLAB.\r\nx = 0:0.01:20;\r\ny1 = 200*exp(-0.05*x).*sin(x);\r\ny2 = 0.8*exp(-0.5*x).*sin(10*x);\r\nplotyy(x,y1,x,y2,'plot');\r\n\r\n%% List of Some Possibilities\r\n% In addition to |plotyy| in MATLAB, here's a list of _some_ of the\r\n% candidates from the File Exchange.\r\n%\r\n% * <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/9016-addaxis  |addaxis|>\r\n% * <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/4425-ploty4-m\r\n% |plot4y|>\r\n% * <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/26550-myplotyy |Myplotyy|>\r\n% * <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/1017-plotyyy\r\n% |plotyyy|>\r\n% * <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/10242-plots-m--plotses-m\r\n% |plots.m plotses.m|>\r\n% * <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/39595-multiplotyyy\r\n% |multiplotyyy|>\r\n%% What are You Plotting with More Y Axes?\r\n% I am curious to know what kind of data or results you are plotting so\r\n% that having multiple y-axes makes a compelling presentation.  Let us know\r\n% <https:\/\/blogs.mathworks.com\/loren\/?p=665#respond here>.\r\n\r\n##### SOURCE END ##### 79a95834e135447399e4a186bba57f16\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2013\/plotyyFEX_01.png\" onError=\"this.style.display ='none';\" \/><\/div><!--introduction--><p>We were musing here about how common it is to want more than two Y axes on a plot.  Checking out the File Exchange, there seem to be several candidates, indicating that this is something at least some people find useful.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2013\/03\/27\/multiple-y-axes\/\">read more >><\/a><\/p>","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[21],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/665"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/comments?post=665"}],"version-history":[{"count":9,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/665\/revisions"}],"predecessor-version":[{"id":735,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/665\/revisions\/735"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}