⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mysuptitle.m

📁 实现地震勘探中
💻 M
字号:
function aux=mysuptitle(text,varargin)% Places text as a "super title" on a group of subplots.% Returns a handle to the super title and a handle to the super axis.% Also saves the title handle in field "SuptitleHandle" of the figure's % application data.% Use function "mnem2tex" if the title string contains inderscores (_) that need% to be preserved(e.g. a variable name or a file name).%% Based on function "suplabel" by Ben Barrowes (Matlab File Exchange)%% Written by: E. R.: December 25, 2005% Last updated: November 17, 2006: Add color option for text%%          title_handle=mysuptitle(text,varargin)% INPUT% text     text for the title% varargin  one or more cell arrays; the first element of each cell array is a%          keyword, the other elements are parameters. Presently, keywords are:%     'color'   Color of text;%          Default: {'color','red'}%     'fontsize'  Size of the title font%          Default: {'fontsize',16}%     'yloc'  relative y-location of the title%          Default: {'yloc',1.00}% OUTPUT% title_handle  handle to the title (allows subsequent changes of the title)%% EXAMPLE%      lfigure%      subplot(2,2,1);ylabel('ylabel1');title('title1')%      subplot(2,2,2);ylabel('ylabel2');title('title2')%      subplot(2,2,3);ylabel('ylabel3');xlabel('xlabel3')%      subplot(2,2,4);ylabel('ylabel4');xlabel('xlabel4')%%      aux=mysuptitle(mnem2tex('Super Title for dataset x_y_z'),{'yloc',0.98});%%      pause(2)%      set(aux.title_handle,'FontSize',10,'Color','blue')%%      set(getappdata(gcf,'SuptitleHandle'),'Color','green')if nargin < 1   error('One input argument with a title string is requred.')endold_axes=gca;figure_handle=gcf;%       Delete suptitle if one alresduy existstitle_handle=getappdata(gcf,'SuptitleHandle');if ~isempty(title_handle)   delete(title_handle)end%	Set defaults for input parametersparam.color='red';param.fontsize=16;param.yloc=1.0;%	Replace defaults by input argumentsparam=assign_input(param,varargin);supAxes=[.08 .08 .84 .84];ah=findall(gcf,'type','axes');if ~isempty(ah)%   supAxes=[inf,inf,0,0];   leftMin=inf;   bottomMin=inf;   leftMax=0;   bottomMax=0;   axBuf=.04;   set(ah,'units','normalized')   ah=findall(gcf,'type','axes');   for ii=1:length(ah)      if strcmp(get(ah(ii),'Visible'),'on')         thisPos=get(ah(ii),'Position');         leftMin=min(leftMin,thisPos(1));         bottomMin=min(bottomMin,thisPos(2));         leftMax=max(leftMax,thisPos(1)+thisPos(3));         temp=thisPos(2)+thisPos(4);         if strcmpi(get(ah(ii),'XAxisLocation'),'top')            temp=temp+0.04;         end         bottomMax=max(bottomMax,temp);      end   end   supAxes=[leftMin-axBuf,bottomMin-axBuf,leftMax-leftMin+axBuf*2, ...            bottomMax-bottomMin+axBuf*2];end%if ~ischar(text)%   error('The first input argument must be a string.')%endaxis_handle=axes('Units','Normal','Position',supAxes,'Visible','off');title_handle=title(text);set(title_handle,'Visible','on','color',param.color,'FontSize',param.fontsize, ...    'Position',[0.5,param.yloc,1])% Save the handle of the suptitlesetappdata(figure_handle,'SuptitleHandle',title_handle)if nargout > 0   aux.axis_handle=axis_handle;   aux.title_handle=title_handle;endset(axis_handle,'HandleVisibility','off');axes(old_axes)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -