{"id":6250,"date":"2015-11-06T09:00:01","date_gmt":"2015-11-06T14:00:01","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=6250"},"modified":"2015-11-04T10:23:01","modified_gmt":"2015-11-04T15:23:01","slug":"does-your-origin-go-through-zero","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2015\/11\/06\/does-your-origin-go-through-zero\/","title":{"rendered":"Does your origin go through zero?"},"content":{"rendered":"<div class=\"content\"><p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a>'s post this week is a short one letting everyone know that one of the many <a href=\"https:\/\/www.mathworks.com\/products\/new_products\/latest_features.html\">new features<\/a> of R2015b, which came out a couple of months ago, is the ability to make the X and Y axes <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/release-notes.html#buwtyz3-1\">go through the origin<\/a>. For many years, people have provided <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/?term=axis+origin\">custom functions<\/a> to create this behavior. Thanks, everyone, for your contributions! If you found those useful, take a look at this new feature, as well as others in this version.<\/p><pre class=\"codeinput\">x = linspace(-pi,pi);\r\ny = sin(x);\r\nplot(x,y)\r\nax = gca;\r\nax.XAxisLocation = <span class=\"string\">'origin'<\/span>;\r\nax.YAxisLocation = <span class=\"string\">'origin'<\/span>;\r\ngrid <span class=\"string\">on<\/span>\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_axesorigin\/potw_axesorigin_01.png\" alt=\"\"> <p><b>Comments<\/b><\/p><p>Let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=6250#respond\">here<\/a>.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_7ac7af74197c44a29404645e4e4295a3() {\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='7ac7af74197c44a29404645e4e4295a3 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 7ac7af74197c44a29404645e4e4295a3';\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 2015 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_7ac7af74197c44a29404645e4e4295a3()\"><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; R2015b<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2015b<br><\/p><\/div><!--\r\n7ac7af74197c44a29404645e4e4295a3 ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\r\n% Jiro>'s post this week is a short one letting everyone know that one of\r\n% the many\r\n% <https:\/\/www.mathworks.com\/products\/new_products\/latest_features.html new\r\n% features> of R2015b, which came out a couple of month ago, is the ability\r\n% to make the X and Y axes\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/release-notes.html#buwtyz3-1 go\r\n% through the origin>. For many years, people have provided\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/?term=axis+origin\r\n% custom functions> to create this behavior. Thanks, everyone, for your\r\n% contributions! If you found those useful, take a look at this new\r\n% feature, as well as others in this version.\r\n\r\nx = linspace(-pi,pi);\r\ny = sin(x);\r\nplot(x,y)\r\nax = gca;\r\nax.XAxisLocation = 'origin';\r\nax.YAxisLocation = 'origin';\r\ngrid on\r\n\r\n%%\r\n% *Comments*\r\n%\r\n% Let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=6250#respond here>.\r\n\r\n##### SOURCE END ##### 7ac7af74197c44a29404645e4e4295a3\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_axesorigin\/potw_axesorigin_01.png\" onError=\"this.style.display ='none';\" \/><\/div><p>Jiro's post this week is a short one letting everyone know that one of the many new features of R2015b, which came out a couple of months ago, is the ability to make the X and Y axes go through the... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2015\/11\/06\/does-your-origin-go-through-zero\/\">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\/6250"}],"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=6250"}],"version-history":[{"count":6,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6250\/revisions"}],"predecessor-version":[{"id":6255,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6250\/revisions\/6255"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=6250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=6250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=6250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}