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