{"id":6081,"date":"2015-07-17T09:00:38","date_gmt":"2015-07-17T13:00:38","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=6081"},"modified":"2015-07-14T03:37:11","modified_gmt":"2015-07-14T07:37:11","slug":"aligning-axes-labels","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2015\/07\/17\/aligning-axes-labels\/","title":{"rendered":"Aligning Axes Labels"},"content":{"rendered":"\r\n\r\n<div class=\"content\"><p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a>'s picks this week are <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/27450-align-axes-labels-in-3d-plot\">Align axes labels in 3D plot<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1591083\">Matthew Arthington<\/a> and <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/49542-phymhan-matlab-axis-label-alignment\">Tools for Axis Label Alignment in 3D Plot<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/4185006\">Ligong Han<\/a>.<\/p><p>When you create a plot, you probably notice a bunch of buttons in the toolbar.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_alignaxislabels\/axisalign_buttons.png\" alt=\"\"> <\/p><p>These buttons have been around for a very long time, so you probably have gotten used to these powerful features. They allow you to quickly explore your data in different ways, i.e. by zooming, panning, and rotating.<\/p><p>But did you know that you could combine these interactive tasks with programmatic tasks? For example, you could make MATLAB tell you the current X and Y limits every time you zoom.<\/p><pre class=\"language-matlab\">plot(rand(10,1))\r\nh = zoom;\r\nh.ActionPostCallback = @(o,e) disp(axis);\r\n<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_alignaxislabels\/axisalign_zoomcallback.png\" alt=\"\"> <\/p><p>This topic was covered in a different blog <a href=\"https:\/\/blogs.mathworks.com\/community\/\">\"MATLAB Spoken Here\"<\/a> in this <a href=\"https:\/\/blogs.mathworks.com\/community\/2007\/12\/10\/focused-on-zooming\/\">post<\/a>. As you can see, this is a feature that has been around for a long time.<\/p><p>The two File Exchange submissions by Matthew and Ligong are perfect for combining with this feature for 3D rotation. They allow for automatic alignment of axes labels when you rotate the figures. Matthew's submission came first. It works well and has a lot of good reviews. One limitation was that it only worked with equal aspect ratio and orthographic projection. Ligong was inspired by this and created a version without this limitation.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_alignaxislabels\/axisalignmovie.gif\" alt=\"\"> <\/p><p><b>Comments<\/b><\/p><p>Give these a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=6081#respond\">here<\/a> or leave a comment for <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/27450-align-axes-labels-in-3d-plot#comments\">Matthew<\/a> or <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/49542-phymhan-matlab-axis-label-alignment#comments\">Ligong<\/a>.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_1344ef00c71547838a6dc7e5584309b0() {\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='1344ef00c71547838a6dc7e5584309b0 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 1344ef00c71547838a6dc7e5584309b0';\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_1344ef00c71547838a6dc7e5584309b0()\"><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; R2015a<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2015a<br><\/p><\/div><!--\r\n1344ef00c71547838a6dc7e5584309b0 ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\r\n% Jiro>'s picks this week are\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/27450-align-axes-labels-in-3d-plot Align axes\r\n% labels in 3D plot> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1591083 Matthew\r\n% Arthington> and\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/49542-phymhan-matlab-axis-label-alignment Tools for Axis\r\n% Label Alignment in 3D Plot> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/4185006 Ligong\r\n% Han>.\r\n%\r\n% When you create a plot, you probably notice a bunch of buttons in the\r\n% toolbar.\r\n%\r\n% <<axisalign_buttons.png>>\r\n%\r\n% These buttons have been around for a very long time, so you probably have\r\n% gotten used to these powerful features. They allow you to quickly explore\r\n% your data in different ways, i.e. by zooming, panning, and rotating.\r\n%\r\n% But did you know that you could combine these interactive tasks with\r\n% programmatic tasks? For example, you could make MATLAB tell you the\r\n% current X and Y limits every time you zoom.\r\n%\r\n%   plot(rand(10,1))\r\n%   h = zoom;\r\n%   h.ActionPostCallback = @(o,e) disp(axis);\r\n%\r\n% <<axisalign_zoomcallback.png>>\r\n%\r\n% This topic was covered in a different blog\r\n% <https:\/\/blogs.mathworks.com\/community\/ \"MATLAB Spoken Here\"> in this\r\n% <https:\/\/blogs.mathworks.com\/community\/2007\/12\/10\/focused-on-zooming\/\r\n% post>. As you can see, this is a feature that has been around for a long\r\n% time.\r\n%\r\n% The two File Exchange submissions by Matthew and Ligong are perfect for\r\n% combining with this feature for 3D rotation. They allow for automatic\r\n% alignment of axes labels when you rotate the figures. Matthew's\r\n% submission came first. It works well and has a lot of good reviews. One\r\n% limitation was that it only worked with equal aspect ratio and\r\n% orthographic projection. Ligong was inspired by this and created a\r\n% version without this limitation.\r\n%\r\n% <<axisalignmovie.gif>>\r\n%\r\n% *Comments*\r\n%\r\n% Give these a try and let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=6081#respond here> or leave a comment\r\n% for <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/27450-align-axes-labels-in-3d-plot#comments\r\n% Matthew> or\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/49542-phymhan-matlab-axis-label-alignment#comments\r\n% Ligong>.\r\n\r\n##### SOURCE END ##### 1344ef00c71547838a6dc7e5584309b0\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_alignaxislabels\/axisalign_buttons.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n\r\nJiro's picks this week are Align axes labels in 3D plot by Matthew Arthington and Tools for Axis Label Alignment in 3D Plot by Ligong Han.When you create a plot, you probably notice a bunch of... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2015\/07\/17\/aligning-axes-labels\/\">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\/6081"}],"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=6081"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6081\/revisions"}],"predecessor-version":[{"id":6085,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6081\/revisions\/6085"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=6081"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=6081"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=6081"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}