-
Notifications
You must be signed in to change notification settings - Fork 0
/
jititle.m
executable file
·54 lines (46 loc) · 1.22 KB
/
jititle.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function hout = jititle(text,fs,option)
% JITITLE JRI's version of TITLE with control of font size.
%
% h = jtitle(text,[fontsize],['inside'])
%
% jri wrapper for axis title:
% default axis + 4 point bold
% if fontsize specified, uses that and normal weight. fs<0 uses default
% additionally, if 'inside' specified, places title inside axis (at top)
% instead of above. Good for v. closely spaced panels
fw='normal'; %for case when fontsize specified
if nargin == 2,
if ischar(fs),
option = fs;
else
option = '';
end
end
if nargin==1 || ischar(fs) || fs < 0,
fs= 4 + get(gca,'fontsize');
fw = 'bold';
end
text = protect_underscore(text);
h=title(text,'FontSize',fs,'FontWeight',fw);
set(h,'verticalalignment','middle')
if nargin >= 2
if strcmp(option,'inside')
pos=get(h,'position');
ax=axis;
ytop=ax(4);
ybot=ax(3);
yrange = ax(4)-ax(3);
if strcmp('PLOT_HEAD',get(gca,'tag')),
pos(2) = 7;
else
pos(2)=ytop-.01*yrange;
end
%pos(1) = pos(1)+.3;
set(h,'position',pos,'verticalalignment','middle');
else
%error('Incorrect option')
end
end
if nargout,
hout = h;
end