0001 function hout=suptitle(str)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 plotregion = .92;
0016
0017
0018 titleypos = .95;
0019
0020
0021 fs = get(gcf,'defaultaxesfontsize')+4;
0022
0023
0024 fudge=1;
0025
0026 haold = gca;
0027 figunits = get(gcf,'units');
0028
0029
0030
0031
0032 if (~strcmp(figunits,'pixels')),
0033 set(gcf,'units','pixels');
0034 pos = get(gcf,'position');
0035 set(gcf,'units',figunits);
0036 else,
0037 pos = get(gcf,'position');
0038 end
0039 ff = (fs-4)*1.27*5/pos(4)*fudge;
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 h = findobj(gcf,'Type','axes');
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 max_y=0;
0066 min_y=1;
0067
0068 oldtitle =0;
0069 for i=1:length(h),
0070 if (~strcmp(get(h(i),'Tag'),'suptitle')),
0071 pos=get(h(i),'pos');
0072 if (pos(2) < min_y), min_y=pos(2)-ff/5*3;end;
0073 if (pos(4)+pos(2) > max_y), max_y=pos(4)+pos(2)+ff/5*2;end;
0074 else,
0075 oldtitle = h(i);
0076 end
0077 end
0078
0079 if max_y > plotregion,
0080 scale = (plotregion-min_y)/(max_y-min_y);
0081 for i=1:length(h),
0082 pos = get(h(i),'position');
0083 pos(2) = (pos(2)-min_y)*scale+min_y;
0084 pos(4) = pos(4)*scale-(1-scale)*ff/5*3;
0085 set(h(i),'position',pos);
0086 end
0087 end
0088
0089 np = get(gcf,'nextplot');
0090 set(gcf,'nextplot','add');
0091 if (oldtitle),
0092 delete(oldtitle);
0093 end
0094 ha=axes('pos',[0 1 1 1],'visible','off','Tag','suptitle');
0095 ht=text(.5,titleypos-1,str);set(ht,'horizontalalignment','center','fontsize',fs);
0096 set(gcf,'nextplot',np);
0097 axes(haold);
0098 if nargout,
0099 hout=ht;
0100 end
0101
0102
0103