{"id":2941,"date":"2011-11-18T13:33:52","date_gmt":"2011-11-18T13:33:52","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2011\/11\/18\/errorbar-with-adjusted-tick-size\/"},"modified":"2011-11-18T13:33:52","modified_gmt":"2011-11-18T13:33:52","slug":"errorbar-with-adjusted-tick-size","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2011\/11\/18\/errorbar-with-adjusted-tick-size\/","title":{"rendered":"Errorbar with Adjusted Tick Size"},"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\/22826-adjust-error-bar-width\">Errorbar with Adjusted Tick<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/30831\">Arnaud Laurent<\/a>.\r\n   <\/p>\r\n   <p>Just this week, I got a <a href=\"https:\/\/blogs.mathworks.com\/loren\/2007\/12\/11\/making-pretty-graphs\/#comment-32652\">comment<\/a> from Felipe on a guest post (<a href=\"https:\/\/blogs.mathworks.com\/loren\/2007\/12\/11\/making-pretty-graphs\/\">\"Making Pretty Graphs\"<\/a>) that I did on Loren's blog. He pointed out this function by Arnaud that helps adjust the size of the horizontal ticks at\r\n      the top and bottom of the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/ref\/errorbar.html\"><tt>errorbars<\/tt><\/a> that I had to fix manually in the post. Thanks Felipe for the tip!\r\n   <\/p>\r\n   <p>The <tt>errorbar<\/tt> automatically determines the tick size based on the limits of the axes, and there is no simple option to change that. However,\r\n      the function can return a handle to <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/ref\/errorbarseriesproperties.html\"><tt>errorbarseries<\/tt><\/a>, and you can modify the tick size by digging into its properties. That's what I did in my blog post. Now, it's even easier\r\n      with Arnaud's <tt>errorbar_tick<\/tt>. I echo Felipe's comment on the entry page that it's nice how <tt>errorbar_tick<\/tt> works on the handle returned by the <tt>errorbar<\/tt> function, rather than recreating the functionality available in <tt>errorbar<\/tt>.\r\n   <\/p>\r\n   <p>Create a standard <tt>errorbar<\/tt> plot:\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">x = 1:10;\r\ny = sin(x);\r\ne = std(y)*ones(size(x));\r\nh = errorbar(x,y,e, <span style=\"color: #A020F0\">'o-'<\/span>);\r\nset(h, <span style=\"color: #A020F0\">'MarkerSize'<\/span>, 10, <span style=\"color: #A020F0\">'MarkerFaceColor'<\/span>, [.3 1 .3], <span style=\"color: #0000FF\">...<\/span>\r\n    <span style=\"color: #A020F0\">'MarkerEdgeColor'<\/span>, [0 .5 0]);<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_errorbar_tick\/potw_errorbar_tick_01.png\"> <p>Apply <tt>errorbar_tick<\/tt> to increase tick size:\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">errorbar_tick(h, 30);<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_errorbar_tick\/potw_errorbar_tick_02.png\"> <p><b>Comments<\/b><\/p>\r\n   <p>Let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2941#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/22826-adjust-error-bar-width#comments\">comment<\/a> for Arnaud.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_c4ac75e45cf14f5fa68b0ba366e1508c() {\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='c4ac75e45cf14f5fa68b0ba366e1508c ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' c4ac75e45cf14f5fa68b0ba366e1508c';\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 = 'Jiro Doke';\r\n        copyright = 'Copyright 2011 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_c4ac75e45cf14f5fa68b0ba366e1508c()\"><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; 7.13<br><\/p>\r\n<\/div>\r\n<!--\r\nc4ac75e45cf14f5fa68b0ba366e1508c ##### 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\/22826-adjust-error-bar-width Errorbar with\r\n% Adjusted Tick> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/30831 Arnaud\r\n% Laurent>.\r\n%\r\n% Just this week, I got a\r\n% <https:\/\/blogs.mathworks.com\/loren\/2007\/12\/11\/making-pretty-graphs\/#comment-32652\r\n% comment> from Felipe on a guest post\r\n% (<https:\/\/blogs.mathworks.com\/loren\/2007\/12\/11\/making-pretty-graphs\/\r\n% \"Making Pretty Graphs\">) that I did on Loren's blog. He pointed out this\r\n% function by Arnaud that helps adjust the size of the horizontal ticks at\r\n% the top and bottom of the\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/ref\/errorbar.html |errorbars|>\r\n% that I had to fix manually in the post. Thanks Felipe for the tip!\r\n%\r\n% The |errorbar| automatically determines the tick size based on the limits\r\n% of the axes, and there is no simple option to change that. However, the\r\n% function can return a handle to\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/ref\/errorbarseriesproperties.html\r\n% |errorbarseries|>, and you can modify the tick size by digging into its\r\n% properties. That's what I did in my blog post. Now, it's even easier with\r\n% Arnaud's |errorbar_tick|. I echo Felipe's comment on the entry page that\r\n% it's nice how |errorbar_tick| works on the handle returned by the\r\n% |errorbar| function, rather than recreating the functionality available\r\n% in |errorbar|.\r\n%\r\n% Create a standard |errorbar| plot:\r\n\r\nx = 1:10;\r\ny = sin(x);\r\ne = std(y)*ones(size(x));\r\nh = errorbar(x,y,e, 'o-');\r\nset(h, 'MarkerSize', 10, 'MarkerFaceColor', [.3 1 .3], ...\r\n    'MarkerEdgeColor', [0 .5 0]);\r\n\r\n%%\r\n% Apply |errorbar_tick| to increase tick size:\r\n\r\nerrorbar_tick(h, 30);\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=2941#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/22826-adjust-error-bar-width#comments\r\n% comment> for Arnaud.\r\n\r\n##### SOURCE END ##### c4ac75e45cf14f5fa68b0ba366e1508c\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   Jiro's pick this week is Errorbar with Adjusted Tick by Arnaud Laurent.\r\n   \r\n   Just this week, I got a comment from Felipe on a guest post (\"Making Pretty Graphs\") that I did on Loren's blog.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2011\/11\/18\/errorbar-with-adjusted-tick-size\/\">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\/2941"}],"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=2941"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2941\/revisions"}],"predecessor-version":[{"id":2974,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2941\/revisions\/2974"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}