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] self : The **implicitly-passed** input argument representing the parent object of the method.<br>
123 %> \param[in] varargin : Any ``property, value`` pair of the parent object.<br>
124 %> If the property is a ``struct()``, then its value must be given as a cell array,
125 %> with consecutive elements representing the struct ``property-name, property-value`` pairs.<br>
126 %> Note that all of these property-value pairs can be also directly set via the
127 %> parent object attributes, before calling the ``make()`` method.<br>
128 %>
129 %> \interface{make}
130 %> \code{.m}
131 %>
132 %> t = pm.vis.Tiling(subplot, varargin);
133 %> t.make(varargin);
134 %>
135 %> \endcode
136 %>
137 %> \final{make}
138 %>
139 %> \author
140 %> \JoshuaOsborne, May 21 2024, 9:24 AM, University of Texas at Arlington<br>
141 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
142 %> \AmirShahmoradi, July 7 2024, 12:53 AM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
143 function make(self, varargin)
144
145 make@pm.vis.figure.Figure(self, varargin{:});
146
147 %%%% Resize the figure to allow good default visualization.
148
149 if isempty(self.figure.outerPosition) && 0 < numel(self.subplot)
150 fullSize = get(0, 'ScreenSize');
151 maxSize = fullSize;
152 maxSize(1:2) = .05 * maxSize(3:4);
153 maxSize(3:4) = maxSize(3:4) - maxSize(1:2);
154 figSize = self.fout.figure.OuterPosition;
155 maxScale = maxSize(3:4) ./ figSize(3:4);
156 newWidth = figSize(3) * min(maxScale(1), size(self.subplot, 2));
157 newHeight = figSize(4) * min(maxScale(2), size(self.subplot, 1));
158 figStart = [(fullSize(3) - newWidth) / 2, (fullSize(4) - newHeight) / 2];
159 set(self.fout.figure, "OuterPosition", [figStart(1:2), newWidth, newHeight]);
160 end
161
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 %%%% RULE 0: No component of ``self`` is allowed to appear to the left of assignment operator, except ``fout``.
164 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165
166 kws = struct();
167 for prop = [ "tiledlayout" ...
168 ]
169 if isprop(self, prop)
170 kws.(prop) = self.comp2hash(prop);
171 end
172 end
173
174 try
175 self.fout.tiledlayout = tiledlayout(size(self.subplot, 1), size(self.subplot, 2), kws.tiledlayout{:}); % requires MATLAB R2019b.
176 end
177 iplt = 0;
178 timer = pm.timing.Timer();
179 spinner = pm.timing.Spinner();
180 for irow = 1 : size(self.subplot, 1)
181 for icol = 1 : size(self.subplot, 2)
182 iplt = iplt + 1;
183 if ~self.silent
184 spinner.spin(iplt / numel(self.subplot));
185 end
186 if pm.introspection.istype(self.subplot{irow, icol}, "pm.vis.Subplot")
187 try
188 nexttile;
189 catch
190 subplot(size(self.subplot, 1), size(self.subplot, 2), iplt);
191 end
192 self.subplot{irow, icol}.make();
193 end
194 end
195 end
196 if ~self.silent && 0 < iplt
197 disp("done in " + sprintf("%.6f", string(timer.toc())) + " seconds.");
198 end
199
200 end % function
201
202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203
204 %> \brief
205 %> Reset the properties of the figure to the original default settings.<br>
206 %>
207 %> \details
208 %> Use this method when you change many attributes of the plot and
209 %> you want to clean up and go back to the default settings.<br>
210 %>
211 %> \param[in] self : The **implicitly-passed** input argument representing the parent object of the method.<br>
212 %> \param[in] varargin : Any ``property, value`` pair of the parent object.<br>
213 %> If the property is a ``struct()``, then its value must be given as a cell array,
214 %> with consecutive elements representing the struct ``property-name, property-value`` pairs.<br>
215 %> Note that all of these property-value pairs can be also directly set via the
216 %> parent object attributes, before calling the ``make()`` method.<br>
217 %>
218 %> \interface{reset}
219 %> \code{.m}
220 %>
221 %> t = pm.vis.Tiling(subplot, varargin)
222 %> t.reset(varargin); % reset all object properties to the default settings.
223 %>
224 %> \endcode
225 %>
226 %> \final{reset}
227 %>
228 %> \author
229 %> \JoshuaOsborne, May 21 2024, 9:25 AM, University of Texas at Arlington<br>
230 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
231 %> \AmirShahmoradi, July 7 2024, 12:53 AM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
232 function reset(self, varargin)
233
234 self.tiledlayout.innerPosition = [];
235 self.tiledlayout.outerPosition = [];
236 self.tiledlayout.position = [];
237 self.tiledlayout.positionConstraint = [];
238 self.tiledlayout.padding = [];
239 self.tiledlayout.tileSpacing = [];
240 self.tiledlayout.units = [];
241
242 reset@pm.vis.figure.Figure(self, varargin{:}); % this will automatically call the ``premake()`` method of the object.
243
244 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
245 %%%% RULE 0: Any non-MATLAB-default setting must be preferably set in the make() method to override user null values.
246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
247
248 %self.premake(varargin{:}); % This is the subclass method!
249
250 end
251
252 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
253
254 %> \brief
255 %> Preset the tiling settings before making it.<br>
256 %>
257 %> \warning
258 %> This method causes side-effects by manipulating
259 %> the existing attributes of the object.<br>
260 %>
261 %> \param[in] self : The **implicitly-passed** input argument representing the parent object of the method.<br>
262 %> \param[in] varargin : Any ``property, value`` pair of the parent object.<br>
263 %> If the property is a ``struct()``, then its value must be given as a cell array,
264 %> with consecutive elements representing the struct ``property-name, property-value`` pairs.<br>
265 %> Note that all of these property-value pairs can be also directly set via the
266 %> parent object attributes, before calling the ``make()`` method.<br>
267 %>
268 %> \interface{premake}
269 %> \code{.m}
270 %>
271 %> t = pm.vis.Tiling(subplot, varargin);
272 %> t.premake(varargin);
273 %>
274 %> \endcode
275 %>
276 %> \final{premake}
277 %>
278 %> \author
279 %> \JoshuaOsborne, May 21 2024, 9:28 AM, University of Texas at Arlington<br>
280 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
281 %> \AmirShahmoradi, July 7 2024, 12:53 AM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
282 function premake(self, varargin)
283
284 premake@pm.vis.figure.Figure(self, varargin{:});
285
286 %self.nrow = size(self.subplot, 1);
287 %self.ncol = size(self.subplot, 2);
288
289 %%%% Set the default margins.
291 self.setKeyVal("tiledlayout", "tileSpacing", "tight");
292 %self.setKeyVal("tiledlayout", "padding", "tight");
293
294 end
295
296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
297
298 end
299
300 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301
302end
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared library directories.
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...