|
a |
|
b/combinedDeepLearningActiveContour/functions/subplot1.m |
|
|
1 |
function h1=subplot1(M,N,varargin) |
|
|
2 |
%------------------------------------------------------------------------- |
|
|
3 |
% subplot1 function An mproved subplot function |
|
|
4 |
% Input : - If more than one input argumenst are given, |
|
|
5 |
% then the first parameter is the number of rows. |
|
|
6 |
% If single input argument is given, then this is the |
|
|
7 |
% subplot-number for which to set focus. |
|
|
8 |
% This could a scalar or two element vector (I,J). |
|
|
9 |
% - Number of columns. |
|
|
10 |
% * variable number of parameters |
|
|
11 |
% (in pairs: ...,Keywoard, Value,...) |
|
|
12 |
% - 'Min' : X, Y lower position of lowest subplot, |
|
|
13 |
% default is [0.10 0.10]. |
|
|
14 |
% - 'Max' : X, Y largest position of highest subplot, |
|
|
15 |
% default is [0.95 0.95]. |
|
|
16 |
% - 'Gap' : X,Y gaps between subplots, |
|
|
17 |
% default is [0.01 0.01]. |
|
|
18 |
% - 'XTickL' : x ticks labels option, |
|
|
19 |
% 'Margin' : plot only XTickLabels in the |
|
|
20 |
% subplot of the lowest row (default). |
|
|
21 |
% 'All' : plot XTickLabels in all subplots. |
|
|
22 |
% 'None' : don't plot XTickLabels in subplots. |
|
|
23 |
% - 'YTickL' : y ticks labels option, |
|
|
24 |
% 'Margin' : plot only YTickLabels in the |
|
|
25 |
% subplot of the lowest row (defailt). |
|
|
26 |
% 'All' : plot YTickLabels in all subplots. |
|
|
27 |
% 'None' : don't plot YTickLabels in subplots. |
|
|
28 |
% - 'FontS' : axis font size, default is 10. |
|
|
29 |
% 'XScale' : scale of x axis: |
|
|
30 |
% 'linear', default. |
|
|
31 |
% 'log' |
|
|
32 |
% - 'YScale' : scale of y axis: |
|
|
33 |
% 'linear', default. |
|
|
34 |
% 'log' |
|
|
35 |
% Example: subplot1(2,2,'Gap',[0.02 0.02]); |
|
|
36 |
% subplot1(2,3,'Gap',[0.02 0.02],'XTickL','None','YTickL','All','FontS',16); |
|
|
37 |
% See also : subplot1c.m |
|
|
38 |
% Tested : Matlab 5.3 |
|
|
39 |
% By : Eran O. Ofek June 2002 |
|
|
40 |
% URL : http://wise-obs.tau.ac.il/~eran/matlab.html |
|
|
41 |
%------------------------------------------------------------------------- |
|
|
42 |
MinDef = [0.10 0.10]; |
|
|
43 |
MaxDef = [0.95 0.95]; |
|
|
44 |
GapDef = [0.01 0.01]; |
|
|
45 |
XTickLDef = 'Margin'; |
|
|
46 |
YTickLDef = 'Margin'; |
|
|
47 |
FontSDef = 10; |
|
|
48 |
XScaleDef = 'linear'; |
|
|
49 |
YScaleDef = 'linear'; |
|
|
50 |
|
|
|
51 |
% set default parameters |
|
|
52 |
Min = MinDef; |
|
|
53 |
Max = MaxDef; |
|
|
54 |
Gap = GapDef; |
|
|
55 |
XTickL = XTickLDef; |
|
|
56 |
YTickL = YTickLDef; |
|
|
57 |
FontS = FontSDef; |
|
|
58 |
XScale = XScaleDef; |
|
|
59 |
YScale = YScaleDef; |
|
|
60 |
|
|
|
61 |
|
|
|
62 |
MoveFoc = 0; |
|
|
63 |
if (nargin==1), |
|
|
64 |
%--- move focus to subplot # --- |
|
|
65 |
MoveFoc = 1; |
|
|
66 |
elseif (nargin==2), |
|
|
67 |
% do nothing |
|
|
68 |
elseif (nargin>2), |
|
|
69 |
Narg = length(varargin); |
|
|
70 |
if (0.5.*Narg==floor(0.5.*Narg)), |
|
|
71 |
|
|
|
72 |
for I=1:2:Narg-1, |
|
|
73 |
switch varargin{I}, |
|
|
74 |
case 'Min' |
|
|
75 |
Min = varargin{I+1}; |
|
|
76 |
case 'Max' |
|
|
77 |
Max = varargin{I+1}; |
|
|
78 |
case 'Gap' |
|
|
79 |
Gap = varargin{I+1}; |
|
|
80 |
case 'XTickL' |
|
|
81 |
XTickL = varargin{I+1}; |
|
|
82 |
case 'YTickL' |
|
|
83 |
YTickL = varargin{I+1}; |
|
|
84 |
case 'FontS' |
|
|
85 |
FontS = varargin{I+1}; |
|
|
86 |
case 'XScale' |
|
|
87 |
XScale = varargin{I+1}; |
|
|
88 |
case 'YScale' |
|
|
89 |
YScale = varargin{I+1}; |
|
|
90 |
otherwise |
|
|
91 |
error('Unknown keyword'); |
|
|
92 |
end |
|
|
93 |
end |
|
|
94 |
else |
|
|
95 |
error('Optional arguments should given as keyword, value'); |
|
|
96 |
end |
|
|
97 |
else |
|
|
98 |
error('Illegal number of input arguments'); |
|
|
99 |
end |
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
switch MoveFoc |
|
|
109 |
case 1 |
|
|
110 |
%--- move focus to subplot # --- |
|
|
111 |
H = get(gcf,'Children'); |
|
|
112 |
Ptot = length(H); |
|
|
113 |
if (length(M)==1), |
|
|
114 |
M = Ptot - M + 1; |
|
|
115 |
elseif (length(M)==2), |
|
|
116 |
%--- check for subplot size --- |
|
|
117 |
Pos1 = get(H(1),'Position'); |
|
|
118 |
Pos1x = Pos1(1); |
|
|
119 |
for Icheck=2:1:Ptot, |
|
|
120 |
PosN = get(H(Icheck),'Position'); |
|
|
121 |
PosNx = PosN(1); |
|
|
122 |
if (PosNx==Pos1x), |
|
|
123 |
NumberOfCol = Icheck - 1; |
|
|
124 |
break; |
|
|
125 |
end |
|
|
126 |
end |
|
|
127 |
NumberOfRow = Ptot./NumberOfCol; |
|
|
128 |
|
|
|
129 |
Row = M(1); |
|
|
130 |
Col = M(2); |
|
|
131 |
|
|
|
132 |
M = (Row-1).*NumberOfCol + Col; |
|
|
133 |
M = Ptot - M + 1; |
|
|
134 |
else |
|
|
135 |
error('Unknown option, undefined subplot index'); |
|
|
136 |
end |
|
|
137 |
|
|
|
138 |
set(gcf,'CurrentAxes',H(M)); |
|
|
139 |
h1=H(M); |
|
|
140 |
case 0 |
|
|
141 |
%--- open subplots --- |
|
|
142 |
|
|
|
143 |
Xmin = Min(1); |
|
|
144 |
Ymin = Min(2); |
|
|
145 |
Xmax = Max(1); |
|
|
146 |
Ymax = Max(2); |
|
|
147 |
Xgap = Gap(1); |
|
|
148 |
Ygap = Gap(2); |
|
|
149 |
|
|
|
150 |
|
|
|
151 |
Xsize = (Xmax - Xmin)./N; |
|
|
152 |
Ysize = (Ymax - Ymin)./M; |
|
|
153 |
|
|
|
154 |
Xbox = Xsize - Xgap; |
|
|
155 |
Ybox = Ysize - Ygap; |
|
|
156 |
|
|
|
157 |
|
|
|
158 |
Ptot = M.*N; |
|
|
159 |
|
|
|
160 |
Hgcf = gcf; |
|
|
161 |
clf; |
|
|
162 |
figure(Hgcf); |
|
|
163 |
for Pi=1:1:Ptot, |
|
|
164 |
Row = ceil(Pi./N); |
|
|
165 |
Col = Pi - (Row - 1)*N; |
|
|
166 |
|
|
|
167 |
Xstart = Xmin + Xsize.*(Col - 1); |
|
|
168 |
Ystart = Ymax - Ysize.*Row; |
|
|
169 |
|
|
|
170 |
% subplot(M,N,Pi); |
|
|
171 |
% hold on; |
|
|
172 |
axes('position',[Xstart,Ystart,Xbox,Ybox]); |
|
|
173 |
%set(gca,'position',[Xstart,Ystart,Xbox,Ybox]); |
|
|
174 |
set(gca,'FontSize',FontS); |
|
|
175 |
box on; |
|
|
176 |
hold on; |
|
|
177 |
|
|
|
178 |
switch XTickL |
|
|
179 |
case 'Margin' |
|
|
180 |
if (Row~=M), |
|
|
181 |
%--- erase XTickLabel --- |
|
|
182 |
set(gca,'XTickLabel',[]); |
|
|
183 |
end |
|
|
184 |
case 'All' |
|
|
185 |
% do nothing |
|
|
186 |
case 'None' |
|
|
187 |
set(gca,'XTickLabel',[]); |
|
|
188 |
otherwise |
|
|
189 |
error('Unknown XTickL option'); |
|
|
190 |
end |
|
|
191 |
|
|
|
192 |
switch YTickL |
|
|
193 |
case 'Margin' |
|
|
194 |
if (Col~=1), |
|
|
195 |
%--- erase YTickLabel --- |
|
|
196 |
set(gca,'YTickLabel',[]); |
|
|
197 |
end |
|
|
198 |
case 'All' |
|
|
199 |
% do nothing |
|
|
200 |
case 'None' |
|
|
201 |
set(gca,'YTickLabel',[]); |
|
|
202 |
otherwise |
|
|
203 |
error('Unknown XTickL option'); |
|
|
204 |
end |
|
|
205 |
|
|
|
206 |
switch XScale |
|
|
207 |
case 'linear' |
|
|
208 |
set(gca,'XScale','linear'); |
|
|
209 |
case 'log' |
|
|
210 |
set(gca,'XScale','log'); |
|
|
211 |
otherwise |
|
|
212 |
error('Unknown XScale option'); |
|
|
213 |
end |
|
|
214 |
|
|
|
215 |
switch YScale |
|
|
216 |
case 'linear' |
|
|
217 |
set(gca,'YScale','linear'); |
|
|
218 |
case 'log' |
|
|
219 |
set(gca,'YScale','log'); |
|
|
220 |
otherwise |
|
|
221 |
error('Unknown YScale option'); |
|
|
222 |
end |
|
|
223 |
|
|
|
224 |
end |
|
|
225 |
|
|
|
226 |
otherwise |
|
|
227 |
error('Unknown MoveFoc option'); |
|
|
228 |
end |