-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmoPlotPos.m
More file actions
57 lines (52 loc) · 1.85 KB
/
moPlotPos.m
File metadata and controls
57 lines (52 loc) · 1.85 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
53
54
55
56
function AxisPos = moPlotPos(nCol, nRow, defPos, space_x, space_y)
% Position of diagrams - a very light SUBPLOT
% Tested: Matlab 6.5, 7.7, 7.8, WinXP
% Author: Jan Simon, Heidelberg, (C) 2005-2011
% This is the percent offset from the subplot grid of the plotbox.
% Formula: Space = a + b * n
% Increase [b] to increase the space between the diagrams.
if nRow < 3
BplusT = 0.18;
else
BplusT = 0.09 + space_y * nRow;
end
if nCol < 3
LplusR = 0.18;
else
LplusR = 0.09 + space_x * nCol;
end
nPlot = nRow * nCol;
plots = 0:(nPlot - 1);
row = (nRow - 1) - fix(plots(:) / nCol);
col = rem(plots(:), nCol);
col_offset = defPos(3) * LplusR / (nCol - LplusR);
row_offset = defPos(4) * BplusT / (nRow - BplusT);
totalwidth = defPos(3) + col_offset;
totalheight = defPos(4) + row_offset;
width = totalwidth / nCol - col_offset;
height = totalheight / nRow - row_offset;
if width * 2 > totalwidth / nCol
if height * 2 > totalheight / nRow
AxisPos = [(defPos(1) + col * totalwidth / nCol), ...
(defPos(2) + row * totalheight / nRow), ...
width(ones(nPlot, 1), 1), ...
height(ones(nPlot, 1), 1)];
else
AxisPos = [(defPos(1) + col * totalwidth / nCol), ...
(defPos(2) + row * defPos(4) / nRow), ...
width(ones(nPlot, 1), 1), ...
(0.7 * defPos(ones(nPlot, 1), 4) / nRow)];
end
else
if height * 2 <= totalheight / nRow
AxisPos = [(defPos(1) + col * defPos(3) / nCol), ...
(defPos(2) + row * defPos(4) / nRow), ...
(0.7 * defPos(ones(nPlot, 1), 3) / nCol), ...
(0.7 * defPos(ones(nPlot, 1), 4) / nRow)];
else
AxisPos = [(defPos(1) + col * defPos(3) / nCol), ...
(defPos(2) + row * totalheight / nRow), ...
(0.7 * defPos(ones(nPlot, 1), 3) / nCol), ...
height(ones(nPlot, 1), 1)];
end
end