-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtsLcSubplotManager.m
More file actions
122 lines (97 loc) · 3.36 KB
/
Copy pathtsLcSubplotManager.m
File metadata and controls
122 lines (97 loc) · 3.36 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
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
classdef tsLcSubplotManager < handle
% tsLcSubplotManager a subplot manager
properties (Access = public)
N % number of rows
M % number of cols
Min = [0.03 0.03];
Max = [0.97 0.97];
Gap = [0.03 0.03];
CellXSize = 300;
CellYSize = 300;
end
properties (Access = private)
axesMap
subSubplotManagers
end
methods
function obj = tsLcSubplotManager(N, M, varargin)
obj.N = N;
obj.M = M;
args.Min = obj.Min;
args.Max = obj.Max;
args.Gap = obj.Gap;
args.CellXSize = obj.CellXSize;
args.CellYSize = obj.CellXSize;
args = tsEasyParseNamedArgs(varargin, args);
obj.Min = args.Min;
obj.Max = args.Max;
obj.Gap = args.Gap;
obj.CellXSize = args.CellXSize;
obj.CellYSize = args.CellYSize;
obj.axesMap = containers.Map('keytype', 'char', 'valuetype', 'any');
obj.subSubplotManagers = containers.Map('keytype', 'char', 'valuetype', 'any');
end
function fg = initFigure(obj)
xSize = obj.CellXSize*obj.M + (obj.Gap(1)*(obj.M - 1));
ySize = obj.CellYSize*obj.N + (obj.Gap(2)*(obj.N - 1));
fg = figure('position', 20 + [0 0 xSize ySize]);
end
function ax = createAxes(obj, AxeName, Row, Col, NRow, NCol, varargin)
if obj.axesMap.isKey(AxeName)
error(['axes ' AxeName ' already exists']);
end
args.Gap = obj.Gap;
args = tsEasyParseNamedArgs(varargin, args);
Gp = args.Gap;
Xmin = obj.Min(1);
Ymin = obj.Min(2);
Xgap = Gp(1);
Ygap = Gp(2);
Xmax = obj.Max(1) + Xgap;
Ymax = obj.Max(2) + Ygap;
Xsize = (Xmax - Xmin)./obj.M;
Ysize = (Ymax - Ymin)./obj.N;
Xbox = Xsize*NCol - Xgap;
Ybox = Ysize*NRow - Ygap;
Xstart = Xmin + Xsize.*(Col - 1);
Ystart = Ymax - Ysize.*Row;
ax = axes('position',[Xstart,Ystart,Xbox,Ybox]);
obj.axesMap(AxeName) = ax;
end
function subSubPlotManager = CreateSubSubplotManager(obj, SubSubplotManagerName, Row, Col, NRow, NCol, NSub, MSub, varargin)
if obj.subSubplotManagers.isKey(SubSubplotManagerName)
error(['axes ' SubSubplotManagerName ' already exists']);
end
args.Gap = obj.Gap;
args.subGap = obj.Gap;
args = tsEasyParseNamedArgs(varargin, args);
Gp = args.Gap;
subGap = args.subGap;
Xmin = obj.Min(1);
Ymin = obj.Min(2);
Xgap = Gp(1);
Ygap = Gp(2);
Xmax = obj.Max(1) + Xgap;
Ymax = obj.Max(2) + Ygap;
Xsize = (Xmax - Xmin)./obj.M;
Ysize = (Ymax - Ymin)./obj.N;
Xbox = Xsize*NCol - Xgap;
Ybox = Ysize*NRow - Ygap;
Xstart = Xmin + Xsize.*(Col - 1);
Ystart = Ymax - Ysize.*Row;
Xend = Xstart + Xbox;
Yend = Ystart + Ybox;
subSubPlotManager = tsLcSubplotManager(NSub, MSub, 'Min', [Xstart, Ystart], 'Max', [Xend, Yend], 'Gap', subGap, varargin{:});
obj.subSubplotManagers(SubSubplotManagerName) = subSubPlotManager;
end
function ax = getAxes(obj, AxeName)
ax = obj.axesMap(AxeName);
end
function sm = getSubSubplotManager(obj, AxeName)
sm = obj.subSubplotManagers(AxeName);
end
function clear(obj)
obj.axesMap = containers.Map('keytype', 'char', 'valuetype', 'any');
end
end
end