{"id":2942,"date":"2011-11-23T22:09:51","date_gmt":"2011-11-23T22:09:51","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2011\/11\/23\/scrolling-figures-guis\/"},"modified":"2011-11-23T22:09:51","modified_gmt":"2011-11-23T22:09:51","slug":"scrolling-figures-guis","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2011\/11\/23\/scrolling-figures-guis\/","title":{"rendered":"Scrolling Figures &#038; GUIs"},"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\/31422\">Ameya<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/7730-scrollsubplot\">Scrollsubplot<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/3111\">Bjorn Gustavsson<\/a>.\r\n   <\/p>\r\n   <p><i>This week, it's an early post because of Thanksgiving holiday here in the U.S.<\/i><\/p>\r\n   <p><i>Hello MATLAB fans! My name is Ameya and I'm a colleague of Jiro and Brett at MathWorks. I primarily support MATLAB users in\r\n         financial services but I'm personally very interested in tool building, visualization and GUIs. This is my first pick as a\r\n         guest on this blog so I hope you enjoy it.<\/i><\/p>\r\n   <p>If you are familiar with any of my submissions, you might know that I'm a big fan of generalizing built-in MATLAB functions\r\n      with wrappers to offer more control or expanded functionality. My pick this week does exactly that. It extends the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/ref\/subplot.html\"><tt>subplot<\/tt><\/a> command to create an infinite canvas of plots with a scroll bar. This can be very useful if you have many visualizations\r\n      to display in a single figure window or GUI but a limited amount of screen real estate. Best of all, because it works just\r\n      like <tt>subplot<\/tt>, you don't need to learn new syntax or modify a lot of existing code. Reviewer Telmo Amaral perhaps says it best: \"This function\r\n      did precisely what I needed in the easiest possible way: just had to replace all the calls to subplot with calls to scrollsubplot.\"\r\n   <\/p>\r\n   <p>For example, suppose we need to display 3 rows of plots on a figure but really only have enough room for 2 rows on screen\r\n      at one time. We can set up just such a canvas with <tt>scrollsubplot<\/tt>:\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #228B22\">% Create a standard 2-row view, similar to _subplot_<\/span>\r\nscrollsubplot(2,1,1); plot(cumsum(randn(200,10)));\r\nscrollsubplot(2,2,3); plot(rand(10,1), rand(10,1), <span style=\"color: #A020F0\">'^'<\/span>);\r\nscrollsubplot(2,2,4); hist(randn(100,1));\r\n\r\n<span style=\"color: #228B22\">% Create axes outside the visible area and generate a scroll bar to bring<\/span>\r\n<span style=\"color: #228B22\">% these axes into view<\/span>\r\nscrollsubplot(2,2,5); imagesc(magic(16));\r\nscrollsubplot(2,2,6); pie(rand(10,1));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/ameya\/pick_2011_11\/pick_2011_11_01.png\"> <p>The figure can be scrolled interactively or with the supporting <tt>scroll<\/tt> function. The final result looks something like the following:\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/ameya\/pick_2011_11\/scrollsubplot_screenshot.gif\"> <\/p>\r\n   <p>Bjorn adds the convenience of using the arrow and the page up\/down keys to scroll through the canvas of axes. I also like\r\n      how he sets up all of the position offset constants at the beginning of his function so that one can easily customize the\r\n      spacing between subplots.\r\n   <\/p>\r\n   <p><b>Comment<\/b><\/p>\r\n   <p>Let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2942#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/7730-scrollsubplot#comments\">comment<\/a> for Bjorn.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_1aab699d1b6947f682960e9fbb4b813c() {\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='1aab699d1b6947f682960e9fbb4b813c ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 1aab699d1b6947f682960e9fbb4b813c';\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 = 'Ameya Deoras';\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_1aab699d1b6947f682960e9fbb4b813c()\"><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\n1aab699d1b6947f682960e9fbb4b813c ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/31422\r\n% Ameya>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/7730-scrollsubplot Scrollsubplot>\r\n% by <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/3111\r\n% Bjorn Gustavsson>.\r\n%\r\n% _This week, it's an early post because of Thanksgiving holiday here in\r\n% the U.S._\r\n%\r\n% _Hello MATLAB fans! My name is Ameya and I'm a colleague of Jiro and\r\n% Brett at MathWorks. I primarily support MATLAB users in financial\r\n% services but I'm personally very interested in tool building,\r\n% visualization and GUIs. This is my first pick as a guest on this blog so\r\n% I hope you enjoy it._\r\n%\r\n% If you are familiar with any of my submissions, you might know that I'm a\r\n% big fan of generalizing built-in MATLAB functions with wrappers to offer\r\n% more control or expanded functionality. My pick this week does exactly\r\n% that. It extends the\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/ref\/subplot.html |subplot|>\r\n% command to create an infinite canvas of plots with a scroll bar. This can\r\n% be very useful if you have many visualizations to display in a single\r\n% figure window or GUI but a limited amount of screen real estate. Best of\r\n% all, because it works just like |subplot|, you don't need to learn new\r\n% syntax or modify a lot of existing code. Reviewer Telmo Amaral perhaps\r\n% says it best: \"This function did precisely what I needed in the easiest\r\n% possible way: just had to replace all the calls to subplot with calls to\r\n% scrollsubplot.\"\r\n% \r\n% For example, suppose we need to display 3 rows of plots on a figure but\r\n% really only have enough room for 2 rows on screen at one time. We can set\r\n% up just such a canvas with |scrollsubplot|:\r\n\r\n% Create a standard 2-row view, similar to _subplot_\r\nscrollsubplot(2,1,1); plot(cumsum(randn(200,10)));\r\nscrollsubplot(2,2,3); plot(rand(10,1), rand(10,1), '^');\r\nscrollsubplot(2,2,4); hist(randn(100,1));\r\n\r\n% Create axes outside the visible area and generate a scroll bar to bring\r\n% these axes into view\r\nscrollsubplot(2,2,5); imagesc(magic(16));\r\nscrollsubplot(2,2,6); pie(rand(10,1));\r\n\r\n%%\r\n% The figure can be scrolled interactively or with the supporting |scroll|\r\n% function. The final result looks something like the following:\r\n% \r\n% <<scrollsubplot_screenshot.gif>>\r\n%\r\n% Bjorn adds the convenience of using the arrow and the page up\/down keys\r\n% to scroll through the canvas of axes. I also like how he sets up all of\r\n% the position offset constants at the beginning of his function so that\r\n% one can easily customize the spacing between subplots.\r\n%\r\n% *Comment*\r\n%\r\n% Let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2942#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/7730-scrollsubplot#comments\r\n% comment> for Bjorn.\r\n\r\n##### SOURCE END ##### 1aab699d1b6947f682960e9fbb4b813c\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   Ameya's pick this week is Scrollsubplot by Bjorn Gustavsson.\r\n   \r\n   This week, it's an early post because of Thanksgiving holiday here in the U.S.\r\n   Hello MATLAB fans! My name is Ameya and... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2011\/11\/23\/scrolling-figures-guis\/\">read more >><\/a><\/p>","protected":false},"author":36,"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\/2942"}],"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\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2942"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2942\/revisions"}],"predecessor-version":[{"id":2975,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2942\/revisions\/2975"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}