{"id":570,"date":"2017-09-14T13:40:43","date_gmt":"2017-09-14T16:40:43","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=570"},"modified":"2017-09-14T13:40:43","modified_gmt":"2017-09-14T16:40:43","slug":"supertitle-m","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/supertitle-m\/","title":{"rendered":"supertitle.m"},"content":{"rendered":"<pre>function hout=supertitle(str)\r\n%SUPERTITLE Puts a title above all subplots.\r\n%       SUPERTITLE('text') adds text to the top of the figure\r\n%       above all subplots (a \"super title\"). Use this function\r\n%       after all subplot commands.\r\n\r\n% Drea Thomas 6\/15\/95 drea@mathworks.com\r\n\r\n% Warning: If the figure or axis units are non-default, this\r\n% will break.\r\n\r\n% Parameters used to position the supertitle.\r\n\r\n% Amount of the figure window devoted to subplots\r\nplotregion = .92;\r\n\r\n% Y position of title in normalized coordinates\r\ntitleypos  = .95;\r\n\r\n% Fontsize for supertitle\r\nfs = get(gcf,'defaultaxesfontsize')+4;\r\n\r\n% Fudge factor to adjust y spacing between subplots\r\nfudge=1;\r\n\r\nhaold = gca;\r\nfigunits = get(gcf,'units');\r\n\r\n% Get the (approximate) difference between full height (plot + title\r\n% + xlabel) and bounding rectangle.\r\n\r\n        if (~strcmp(figunits,'pixels')),\r\n                set(gcf,'units','pixels');\r\n                pos = get(gcf,'position');\r\n                set(gcf,'units',figunits);\r\n        else,\r\n                pos = get(gcf,'position');\r\n        end\r\n        ff = (fs-4)*1.27*5\/pos(4)*fudge;\r\n\r\n        % The 5 here reflects about 3 characters of height below\r\n        % an axis and 2 above. 1.27 is pixels per point.\r\n\r\n% Determine the bounding rectange for all the plots\r\n\r\n% h = findobj('Type','axes');   \r\n\r\n% findobj is a 4.2 thing.. if you don't have 4.2 comment out\r\n% the next line and uncomment the following block.\r\n        \r\nh = findobj(gcf,'Type','axes');  % Change suggested by Stacy J. Hills\r\n\r\n% If you don't have 4.2, use this code instead\r\n%ch = get(gcf,'children');\r\n%h=[];\r\n%for i=1:length(ch),\r\n%  if strcmp(get(ch(i),'type'),'axes'),\r\n%    h=[h,ch(i)];\r\n%  end\r\n%end\r\n\r\n        \r\n\r\n\r\nmax_y=0;\r\nmin_y=1;\r\n\r\noldtitle =0;\r\nfor i=1:length(h),\r\n        if (~strcmp(get(h(i),'Tag'),'suptitle')),\r\n                pos=get(h(i),'pos');\r\n                if (pos(2) &lt; min_y), min_y=pos(2)-ff\/5*3;end;\r\n                if (pos(4)+pos(2) &gt; max_y), max_y=pos(4)+pos(2)+ff\/5*2;end;\r\n        else,\r\n                oldtitle = h(i);\r\n        end\r\nend\r\n\r\nif max_y &gt; plotregion,\r\n        scale = (plotregion-min_y)\/(max_y-min_y);\r\n        for i=1:length(h),\r\n                pos = get(h(i),'position');\r\n                pos(2) = (pos(2)-min_y)*scale+min_y;\r\n                pos(4) = pos(4)*scale-(1-scale)*ff\/5*3;\r\n                set(h(i),'position',pos);\r\n        end\r\nend\r\n\r\nnp = get(gcf,'nextplot');\r\nset(gcf,'nextplot','add');\r\nif (oldtitle),\r\n        delete(oldtitle);\r\nend\r\nha=axes('pos',[0 1 1 1],'visible','off','Tag','suptitle');\r\nht=text(.5,titleypos-1,str);set(ht,'horizontalalignment','center','fontsize',fs);\r\nset(gcf,'nextplot',np);\r\naxes(haold);\r\nif nargout,\r\n        hout=ht;\r\nend\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>function hout=supertitle(str) %SUPERTITLE Puts a title above all subplots. % SUPERTITLE(&#8216;text&#8217;) adds text to the top of the figure % above all subplots (a &#8220;super title&#8221;). Use this function % after all subplot commands. % Drea Thomas 6\/15\/95 drea@mathworks.com % Warning: If the figure or axis units are non-default, this % will break. % Parameters [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[],"tags":[],"class_list":["post-570","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/comments?post=570"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/570\/revisions"}],"predecessor-version":[{"id":571,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/570\/revisions\/571"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}