-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathTickLabelRotate.m
More file actions
52 lines (50 loc) · 1.38 KB
/
TickLabelRotate.m
File metadata and controls
52 lines (50 loc) · 1.38 KB
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
function TickLabelRotate(AX_handle,tag,rot,HorizontalAlignment,UpDown)
% ×ø±êTickLabelÐýת
% by LiYang
% Email:farutoliyang@gmail.com
% 2012/5/25
% Matlab Version : Matlab R2011b
%%
if nargin < 5
% 1 Down 2 Up 3 Left 4 Right
UpDown = 1;
end
if nargin < 4
HorizontalAlignment = 'right';
% left | center | right
end
if nargin < 3
rot = 60;
end
if nargin < 2
tag = 'x';
end
%%
switch tag
case 'x'
str = get(AX_handle,'XTickLabel');
x = get(AX_handle,'XTick');
yl = ylim(AX_handle);
set(AX_handle,'XTickLabel',[]);
if UpDown == 1
y = zeros(size(x)) + yl(1) - range(yl)/80;
end
if UpDown == 2
y = zeros(size(x)) + yl(end) + range(yl)/80;
end
text(x,y,str,'rotation',rot,...
'Interpreter','none','HorizontalAlignment',HorizontalAlignment);
case 'y'
str = get(AX_handle,'YTickLabel');
y = get(AX_handle,'YTick');
xl = xlim(AX_handle);
set(AX_handle,'YTickLabel',[]);
if UpDown == 3
x = zeros(size(y)) + xl(1) - range(xl)/80;
end
if UpDown == 4
x = zeros(size(y)) + xl(end) + range(xl)/80;
end
text(x,y,str,'rotation',rot,...
'Interpreter','none','HorizontalAlignment',HorizontalAlignment);
end