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