{"id":4870,"date":"2013-10-18T09:00:46","date_gmt":"2013-10-18T13:00:46","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=4870"},"modified":"2013-10-17T19:30:34","modified_gmt":"2013-10-17T23:30:34","slug":"zoomable-text","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2013\/10\/18\/zoomable-text\/","title":{"rendered":"Zoomable Text"},"content":{"rendered":"\r\n<div class=\"content\"><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\/41513-textzoomable-x-y-varargin-\"><tt>TextZoomable<\/tt><\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/29904\">Ken Purchase<\/a>.<\/p><p>Today's entry was inspired by my colleague, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/204413\">Sean<\/a>, who also guest posts for this blog from time to time. He and I are application engineers, traveling around the country evangelizing about MATLAB. We once traveled together, and I saw him present a seminar on image processing, which by the way was created by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/911\">Brett<\/a>. During the seminar, Sean showed an image that had some annotation to indicate that he was able to successfully differentiate straight lines from curvy lines, just by using image processing techniques. Because the auditorium was pretty big, some of the people in the back had difficulty reading the text. Sean promptly zoomed in using the zoom tool built into the figure.<\/p><p>Then I noticed something. The text became larger along with the image! Later, Sean told me that he was using a File Exchange entry that automatically scaled text when zooming. That was Ken's entry.<\/p><p>In the example below, I have added two text objects, one using MATLAB's <a href=\"\"><tt>text<\/tt><\/a> function (red) and the other using Ken's <tt>TextZoomable<\/tt> (blue). The syntax is exactly the same as that of <tt>text<\/tt>, so it's very easy to swap out the commands.<\/p><pre class=\"codeinput\">x  = -pi\/2:0.01:pi\/2;\r\ny1 = 0.5*tan(0.8*x);\r\ny2 = -0.7*tan(0.8*x);\r\n\r\nplot(x, y1, <span class=\"string\">'b'<\/span>, x, y2, <span class=\"string\">'r'<\/span>)\r\nxlabel(<span class=\"string\">'theta (\\theta)'<\/span>)\r\nylabel(<span class=\"string\">'value (\\psi)'<\/span>)\r\n\r\ntext(x(80), y2(80), <span class=\"string\">'\\leftarrow \\psi = -.7tan(.8\\theta)'<\/span>, <span class=\"keyword\">...<\/span>\r\n  <span class=\"string\">'FontAngle'<\/span>, <span class=\"string\">'italic'<\/span>, <span class=\"keyword\">...<\/span>\r\n  <span class=\"string\">'Color'<\/span>, <span class=\"string\">'red'<\/span>);\r\nTextZoomable(x(80),y1(80),<span class=\"string\">'\\leftarrow \\psi = .5tan(.8\\theta)'<\/span>, <span class=\"keyword\">...<\/span>\r\n  <span class=\"string\">'FontAngle'<\/span>, <span class=\"string\">'italic'<\/span>, <span class=\"keyword\">...<\/span>\r\n  <span class=\"string\">'Color'<\/span>, <span class=\"string\">'blue'<\/span>);\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_zoomabletext\/potw_zoomabletext_01.png\" alt=\"\"> <p>Now, if I zoom in (note that you can do this interactively using the zoom tool), the blue text scales nicely with the zoom.<\/p><pre class=\"codeinput\">zoom(2)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_zoomabletext\/potw_zoomabletext_02.png\" alt=\"\"> <p>This is great! This is a must-have for anyone presenting MATLAB graphics with annotation.<\/p><p><b>Comments<\/b><\/p><p>Let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=4870#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/41513-textzoomable-x-y-varargin-#comments\">comment<\/a> for Ken.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_b0d07893280e45c1b9681683b254475e() {\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='b0d07893280e45c1b9681683b254475e ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' b0d07893280e45c1b9681683b254475e';\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_b0d07893280e45c1b9681683b254475e()\"><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; R2013b<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2013b<br><\/p><\/div><!--\r\nb0d07893280e45c1b9681683b254475e ##### 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\/41513-textzoomable-x-y-varargin-\r\n% |TextZoomable|> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/29904 Ken\r\n% Purchase>.\r\n%\r\n% Today's entry was inspired by my colleague,\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/204413\r\n% Sean>, who also guest posts for this blog from time to time. He and I are\r\n% application engineers, traveling around the country evangelizing about\r\n% MATLAB. We once traveled together, and I saw him present a seminar on\r\n% image processing, which by the way was created by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/911 Brett>.\r\n% During the seminar, Sean showed an image that had some annotation to\r\n% indicate that he was able to successfully differentiate straight lines\r\n% from curvy lines, just by using image processing techniques. Because the\r\n% auditorium was pretty big, some of the people in the back had difficulty\r\n% reading the text. Sean promptly zoomed in using the zoom tool built into\r\n% the figure.\r\n%\r\n% Then I noticed something. The text became larger along with the image!\r\n% Later, Sean told me that he was using a File Exchange entry that\r\n% automatically scaled text when zooming. That was Ken's entry.\r\n%\r\n% In the example below, I have added two text objects, one using MATLAB's\r\n% <\r\n% |text|> function (red) and the other using Ken's |TextZoomable| (blue).\r\n% The syntax is exactly the same as that of |text|, so it's very easy to\r\n% swap out the commands.\r\n\r\nx  = -pi\/2:0.01:pi\/2;\r\ny1 = 0.5*tan(0.8*x);\r\ny2 = -0.7*tan(0.8*x);\r\n\r\nplot(x, y1, 'b', x, y2, 'r')\r\nxlabel('theta (\\theta)')\r\nylabel('value (\\psi)')\r\n\r\ntext(x(80), y2(80), '\\leftarrow \\psi = -.7tan(.8\\theta)', ...\r\n  'FontAngle', 'italic', ...\r\n  'Color', 'red');\r\nTextZoomable(x(80),y1(80),'\\leftarrow \\psi = .5tan(.8\\theta)', ...\r\n  'FontAngle', 'italic', ...\r\n  'Color', 'blue');\r\n\r\n%%\r\n% Now, if I zoom in (note that you can do this interactively using the zoom\r\n% tool), the blue text scales nicely with the zoom.\r\n\r\nzoom(2)\r\n\r\n%%\r\n% This is great! This is a must-have for anyone presenting MATLAB graphics\r\n% with annotation.\r\n%\r\n% *Comments*\r\n%\r\n% Let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=4870#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/41513-textzoomable-x-y-varargin-#comments\r\n% comment> for Ken.\r\n\r\n##### SOURCE END ##### b0d07893280e45c1b9681683b254475e\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_zoomabletext\/potw_zoomabletext_01.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\nJiro's pick this week is TextZoomable by Ken Purchase.Today's entry was inspired by my colleague, Sean, who also guest posts for this blog from time to time. He and I are application engineers,... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2013\/10\/18\/zoomable-text\/\">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\/4870"}],"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=4870"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/4870\/revisions"}],"predecessor-version":[{"id":4872,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/4870\/revisions\/4872"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=4870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=4870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=4870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}