-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathisAxisExist.m
134 lines (131 loc) · 5.11 KB
/
isAxisExist.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
function re = isAxisExist(hAxis,axisName)
% Author: 巴山 (bashan)
% Email: moveon5@163.com
% QQ Group: 531421022 (MATLAB编程爱好者)
% Welcome to subscribe matlabaihaozhe (WeChat) and join our QQ group.
% 欢迎关注matlab爱好者微信公众号和加入QQ群.
% Please feel free to contact me if you have any questions.
% 程序使用过程中如遇问题请随时联系作者!
% isAxisExist —— Check existence of Axis
% isAxisExist returns:
% true if Axis exists
% false if Axis existdoes not
len = length(hAxis);
if len == 1
re = false;
else
for k = 1:len-1
xloc = get(hAxis(k),'XAxisLocation');
yloc = get(hAxis(k),'YAxisLocation');
xlim = get(hAxis(k),'XLim');
ylim = get(hAxis(k),'YLim');
xt = get(hAxis(k),'XTick');
xtlab = get(hAxis(k),'XTickLabel');
yt = get(hAxis(k),'YTick');
ytlab = get(hAxis(k),'YTickLabel');
xmtv = hAxis(k).XAxis.MinorTickValues;
ymtv = hAxis(k).YAxis.MinorTickValues;
xmt = get(hAxis(k),'XMinorTick');
ymt = get(hAxis(k),'YMinorTick');
xc = get(hAxis(k),'XColor');
yc = get(hAxis(k),'YColor');
switch axisName
case 'bottomMajor'
con1 = isequal(xloc,'bottom') && isequal(yloc,'left');
con2 = ~isempty(yt) && isequal(sum(ylim),1) && ~isempty(ytlab);
con3 = isequal(ymt,'on');
con4 = isequal(yc,'none');
con5 = isempty(xmtv);
if con1 && con2 && con3 && con4 && con5
re = true;
break;
else
re = false;
end
case 'bottomMinor'
con1 = isequal(xloc,'bottom') && isequal(yloc,'left');
con2 = isempty(yt) && isequal(sum(ylim),0) && isempty(ytlab);
con3 = isequal(ymt,'off');
con4 = isequal(yc,'none');
con5 = ~isempty(xmtv);
if con1 && con2 && con3 && con4 && con5
re = true;
break;
else
re = false;
end
case 'topMajor'
con1 = isequal(xloc,'top') && isequal(yloc,'left');
con2 = ~isempty(yt) && isequal(sum(ylim),1) && ~isempty(ytlab);
con3 = isequal(ymt,'on');
con4 = isequal(yc,'none');
con5 = isempty(xmtv);
if con1 && con2 && con3 && con4 && con5
re = true;
break;
else
re = false;
end
case 'topMinor'
con1 = isequal(xloc,'top') && isequal(yloc,'left');
con2 = isempty(yt) && isequal(sum(ylim),0) && isempty(ytlab);
con3 = isequal(ymt,'off');
con4 = isequal(yc,'none');
con5 = ~isempty(xmtv);
if con1 && con2 && con3 && con4 && con5
re = true;
break;
else
re = false;
end
case 'leftMajor'
con1 = isequal(xloc,'bottom') && isequal(yloc,'left');
con2 = ~isempty(xt) && isequal(sum(xlim),1) && ~isempty(xtlab);
con3 = isequal(xmt,'on');
con4 = isequal(xc,'none');
con5 = isempty(ymtv);
if con1 && con2 && con3 && con4 && con5
re = true;
break;
else
re = false;
end
case 'leftMinor'
con1 = isequal(xloc,'bottom') && isequal(yloc,'left');
con2 = isempty(xt) && isequal(sum(xlim),0) && isempty(xtlab);
con3 = isequal(xmt,'off');
con4 = isequal(xc,'none');
con5 = ~isempty(ymtv);
if con1 && con2 && con3 && con4 && con5
re = true;
break;
else
re = false;
end
case 'rightMajor'
con1 = isequal(xloc,'bottom') && isequal(yloc,'right');
con2 = ~isempty(xt) && isequal(sum(xlim),1) && ~isempty(xtlab);
con3 = isequal(xmt,'on');
con4 = isequal(xc,'none');
con5 = isempty(ymtv);
if con1 && con2 && con3 && con4 && con5
re = true;
break;
else
re = false;
end
case 'rightMinor'
con1 = isequal(xloc,'bottom') && isequal(yloc,'right');
con2 = isempty(xt) && isequal(sum(xlim),0) && isempty(xtlab);
con3 = isequal(xmt,'off');
con4 = isequal(xc,'none');
con5 = ~isempty(ymtv);
if con1 && con2 && con3 && con4 && con5
re = true;
break;
else
re = false;
end
end
end
end