ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
Tiling.m
Go to the documentation of this file.
1%> \brief
2%> This is the base class for generating instances
3%> of figures containing a tile of subplots.<br>
4%>
5%> \note
6%> See the list of class attributes below,
7%> also those of the superclass [pm.vis.figure.Figure](@ref Figure).<br>
8%>
9%> \note
10%> See also the documentation of the constructor of the class [pm.vis.Tiling::Tiling](@ref Tiling::Tiling).<br>
11%>
12%> \final
13%>
14%> \author
15%> \JoshuaOsborne, May 21 2024, 9:20 AM, University of Texas at Arlington<br>
16%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
17%> \AmirShahmoradi, July 7 2024, 12:53 AM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
18classdef Tiling < pm.vis.figure.Figure
19
20 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21
22 properties(Access = public)
23 %>
24 %> ``tiledlayout``
25 %>
26 %> A MATLAB ``struct`` whose fields and values are passed
27 %> as keyword arguments to the MATLAB intrinsic ``tiledlayout()``.<br>
28 %>
29 tiledlayout = [];
30 %>
31 %> ``subplot``
32 %>
33 %> The MATLAB cell matrix containing objects of superclass [pm.vis.Subplot](@ref Subplot)
34 %> each of which represents one subplot axes to display in the figure.<br>
35 %>
36 subplot = cell(0, 0);
37 end
38
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 methods(Access = public)
42
43 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44
45 %> \brief
46 %> Construct and return an object of class [pm.vis.Tiling](@ref Tiling).<br>
47 %>
48 %> \details
49 %> This is the constructor of the class [pm.vis.Tiling](@ref Tiling).<br>
50 %>
51 %> \param[in] subplot : The input cell matrix of MATLAB objects of superclass [pm.vis.Subplot](@ref Subplot).<br>
52 %> \param[in] varargin : Any ``property, value`` pair of the parent object.<br>
53 %> If the property is a ``struct()``, then its value must be given as a cell array,
54 %> with consecutive elements representing the struct ``property-name, property-value`` pairs.<br>
55 %> Note that all of these property-value pairs can be also directly set via the
56 %> parent object attributes, before calling the ``make()`` method.<br>
57 %>
58 %> \return
59 %> ``self`` : The output scalar object of class [pm.vis.Tiling](@ref Tiling).<br>
60 %>
61 %> \interface{Tiling}
62 %> \code{.m}
63 %>
64 %> t = pm.vis.Tiling(subplot);
65 %> t = pm.vis.Tiling(subplot, varargin);
66 %>
67 %> \endcode
68 %>
69 %> \note
70 %> See the list of class attributes below,
71 %> also those of the superclass [pm.vis.figure.Figure](@ref Figure).<br>
72 %>
73 %> \final{Tiling}
74 %>
75 %> \author
76 %> \JoshuaOsborne, May 21 2024, 9:20 AM, University of Texas at Arlington<br>
77 function self = Tiling(subplot, varargin)
78 if nargin < 1
79 subplot = cell(0, 0);
80 end
81 failed = ~iscell(subplot);
82 if ~failed
83 for irow = 1 : size(subplot, 1)
84 for icol = 1 : size(subplot, 2)
85 failed = ~isempty(subplot{irow, icol}) && ~pm.introspection.istype(subplot{irow, icol}, "pm.vis.Subplot");
86 if failed
87 break;
88 end
89 end
90 if failed
91 break;
92 end
93 end
94 end
95 if ~failed
96 varargin = {"subplot", subplot, varargin{:}};
97 else
98 help("pm.vis.Tiling");
99 error ( newline ...
100 + "The input argument ``subplot`` must be a MATLAB cell matrix of " + newline ...
101 + "empty objects or objects of superclass [pm.vis.Subplot](@ref Subplot)." + newline ...
102 + "For more information, see the class documentation displayed above." + newline ...
103 + newline ...
104 );
105 end
106 self = self@pm.vis.figure.Figure(varargin{:});
107 end
108
109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110
111 %> \brief
112 %> Configure the figure settings and specifications,
113 %> make the figure and the subplots, and return nothing.<br>
114 %>
115 %> \details
116 %> The subplots are made by calling their ``make()`` methods.<br>
117 %>
118 %> \warning
119 %> This method has side-effects by manipulating
120 %> the existing attributes of the parent object.<br>
121 %>
122 %> \param[in] varargin : Any ``property, value`` pair of the parent object.<br>
123 %> If the property is a ``struct()``, then its value must be given as a cell array,
124 %> with consecutive elements representing the struct ``property-name, property-value`` pairs.<br>
125 %> Note that all of these property-value pairs can be also directly set via the
126 %> parent object attributes, before calling the ``make()`` method.<br>
127 %>
128 %> \interface{make}
129 %> \code{.m}
130 %>
131 %> t = pm.vis.Tiling(subplot, varargin);
132 %> t.make(varargin);
133 %>
134 %> \endcode
135 %>
136 %> \final{make}
137 %>
138 %> \author
139 %> \JoshuaOsborne, May 21 2024, 9:24 AM, University of Texas at Arlington<br>
140 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
141 %> \AmirShahmoradi, July 7 2024, 12:53 AM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
142 function make(self, varargin)
143
144 make@pm.vis.figure.Figure(self, varargin{:});
145
146 %%%% Resize the figure to allow good default visualization.
147
148 if isempty(self.figure.outerPosition) && 0 < numel(self.subplot)
149 fullSize = get(0, 'ScreenSize');
150 maxSize = fullSize;
151 maxSize(1:2) = .05 * maxSize(3:4);
152 maxSize(3:4) = maxSize(3:4) - maxSize(1:2);
153 figSize = self.fout.figure.OuterPosition;
154 maxScale = maxSize(3:4) ./ figSize(3:4);
155 newWidth = figSize(3) * min(maxScale(1), size(self.subplot, 2));
156 newHeight = figSize(4) * min(maxScale(2), size(self.subplot, 1));
157 figStart = [(fullSize(3) - newWidth) / 2, (fullSize(4) - newHeight) / 2];
158 set(self.fout.figure, "OuterPosition", [figStart(1:2), newWidth, newHeight]);
159 end
160
161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
162 %%%% RULE 0: No component of ``self`` is allowed to appear to the left of assignment operator, except ``fout``.
163 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
164
165 kws = struct();
166 for prop = [ "tiledlayout" ...
167 ]
168 if isprop(self, prop)
169 kws.(prop) = self.comp2hash(prop);
170 end
171 end
172
173 try
174 self.fout.tiledlayout = tiledlayout(size(self.subplot, 1), size(self.subplot, 2), kws.tiledlayout{:}); % requires MATLAB R2019b.
175 end
176 iplt = 0;
177 timer = pm.timing.Timer();
178 spinner = pm.timing.Spinner();
179 for irow = 1 : size(self.subplot, 1)
180 for icol = 1 : size(self.subplot, 2)
181 iplt = iplt + 1;
182 spinner.spin(iplt / numel(self.subplot));
183 if pm.introspection.istype(self.subplot{irow, icol}, "pm.vis.Subplot")
184 try
185 nexttile;
186 catch
187 subplot(size(self.subplot, 1), size(self.subplot, 2), iplt);
188 end
189 self.subplot{irow, icol}.make();
190 end
191 end
192 end
193 if 0 < iplt
194 disp("done in " + sprintf("%.6f", string(timer.toc())) + " seconds.");
195 end
196
197 end % function
198
199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
200
201 %> \brief
202 %> Reset the properties of the figure to the original default settings.<br>
203 %>
204 %> \details
205 %> Use this method when you change many attributes of the plot and
206 %> you want to clean up and go back to the default settings.<br>
207 %>
208 %> \param[in] varargin : Any ``property, value`` pair of the parent object.<br>
209 %> If the property is a ``struct()``, then its value must be given as a cell array,
210 %> with consecutive elements representing the struct ``property-name, property-value`` pairs.<br>
211 %> Note that all of these property-value pairs can be also directly set via the
212 %> parent object attributes, before calling the ``make()`` method.<br>
213 %>
214 %> \interface{reset}
215 %> \code{.m}
216 %>
217 %> t = pm.vis.Tiling(subplot, varargin) % reset all object properties to the default settings.
218 %> t.reset(varargin);
219 %>
220 %> \endcode
221 %>
222 %> \final{reset}
223 %>
224 %> \author
225 %> \JoshuaOsborne, May 21 2024, 9:25 AM, University of Texas at Arlington<br>
226 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
227 %> \AmirShahmoradi, July 7 2024, 12:53 AM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
228 function reset(self, varargin)
229
230 self.tiledlayout.innerPosition = [];
231 self.tiledlayout.outerPosition = [];
232 self.tiledlayout.position = [];
233 self.tiledlayout.positionConstraint = [];
234 self.tiledlayout.padding = [];
235 self.tiledlayout.tileSpacing = [];
236 self.tiledlayout.units = [];
237
238 reset@pm.vis.figure.Figure(self, varargin{:}); % this will automatically call the ``premake()`` method of the object.
239
240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
241 %%%% RULE 0: Any non-MATLAB-default setting must be preferably set in the make() method to override user null values.
242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243
244 %self.premake(varargin{:}); % This is the subclass method!
245
246 end
247
248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
249
250 %> \brief
251 %> Preset the tiling settings before making it.<br>
252 %>
253 %> \warning
254 %> This method causes side-effects by manipulating
255 %> the existing attributes of the object.<br>
256 %>
257 %> \param[in] varargin : Any ``property, value`` pair of the parent object.<br>
258 %> If the property is a ``struct()``, then its value must be given as a cell array,
259 %> with consecutive elements representing the struct ``property-name, property-value`` pairs.<br>
260 %> Note that all of these property-value pairs can be also directly set via the
261 %> parent object attributes, before calling the ``make()`` method.<br>
262 %>
263 %> \interface{premake}
264 %> \code{.m}
265 %>
266 %> t = pm.vis.Tiling(subplot, varargin);
267 %> t.premake(varargin);
268 %>
269 %> \endcode
270 %>
271 %> \example{premake}
272 %>
273 %> \final{premake}
274 %>
275 %> \author
276 %> \JoshuaOsborne, May 21 2024, 9:28 AM, University of Texas at Arlington<br>
277 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
278 %> \AmirShahmoradi, July 7 2024, 12:53 AM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
279 function premake(self, varargin)
280
281 premake@pm.vis.figure.Figure(self, varargin{:});
282
283 %self.nrow = size(self.subplot, 1);
284 %self.ncol = size(self.subplot, 2);
285
286 %%%% Set the default margins.
288 self.setKeyVal("tiledlayout", "tileSpacing", "tight");
289 %self.setKeyVal("tiledlayout", "padding", "tight");
290
291 end
292
293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
294
295 end
296
297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
298
299end
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared libraries.
function list()
Return a list of MATLAB strings containing the names of OS platforms supported by the ParaMonte MATLA...
This is the abstract class for generating instances of objects that contain the specifications of var...
Definition: Figure.m:27
This is the abstract class for generating instances of axes with various types of plots from one or m...
Definition: Subplot.m:188
This is the base class for generating instances of figures containing a tile of subplots.
Definition: Tiling.m:19
function make(in self, in varargin)
Configure the figure settings and specifications, make the figure and the subplots,...
function premake(in self, in varargin)
Preset the tiling settings before making it.
Property subplot
Definition: Tiling.m:40
Property tiledlayout
Definition: Tiling.m:32
function Tiling(in subplot, in varargin)
Construct and return an object of class pm.vis.Tiling.
function reset(in self, in varargin)
Reset the properties of the figure to the original default settings.
function clean()
Remove all paths that contain the ParaMonte lib directory from the MATLAB path variable.
function istype(in varval, in vartype, in varsize)
Return true if and only if the input varval conforms with the specified input type vartype and the sp...
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...