1 changed files with 37 additions and 0 deletions
@ -0,0 +1,37 @@
|
||||
function handle=header(xpos,ypos,string,varargin) |
||||
|
||||
% HEADER(xpos,ypos,string) Write a text string in a |
||||
% specified place on the current figure. |
||||
% A bogus set of axes is used - so it's best to call |
||||
% this LAST, especially if using SUBPLOT. |
||||
% |
||||
% By default, the fontsize is 6pt larger than current default, |
||||
% and text alignment is center/top. |
||||
% |
||||
% Required Inputs: |
||||
% xpos,ypos the location (0.5,1 is centre top) |
||||
% string the input string |
||||
% Optional Inputs: |
||||
% varargin any TEXT arguments |
||||
|
||||
h=gca; |
||||
fsize=get(h,'FontSize')+6; |
||||
|
||||
if isempty(xpos), xpos=0.5;, end |
||||
if isempty(ypos), ypos=1;, end |
||||
|
||||
k=find(strncmp(varargin,'fontsiz',7)); |
||||
if isempty(k), varargin={varargin{:},'fontsize',fsize};, end |
||||
varargin={varargin{:},'horizontalalignment','center','verticalalignment','top'}; |
||||
|
||||
% Get current axes handle and create big invisible axes |
||||
|
||||
hnow=get(gcf,'currentaxes'); |
||||
|
||||
h=axes('Position',[0 0 1 1],'Visible','off'); |
||||
puttext(xpos,ypos,string,varargin{:}) |
||||
|
||||
% Return control to old axes |
||||
|
||||
set(gcf,'currentaxes',hnow) |
||||
if nargout>0, handle=h;, end |
Loading…
Reference in new issue