2%> This is the base
class for generating instances of objects that contains
3%> layout information
for a set of tiled subplots in a single figure.<br>
6%> For more information, see the documentation of the
class constructor
10%> This
class is not meant to be used directly by the end users.<br>
11%> Instead, use other classes that internally use
this class as a component.<br>
14%> See the
list of
class attributes below,
15%> also those of the superclass [pm.matlab.Handle](@ref
Handle).<br>
18%> The tiling layout generated by
this class is different from new MATLAB ``tiledlayout``.<br>
19%> Specifically,
this class aims to mimic the layout originally devised the first
version of ParaMonte MATLAB library
release.<br>
20%> This ParaMonte tiling layout is,
for example, used in making corner plots (formerly known as ``GridPlot`` in ParaMonte V1).<br>
25%> \AmirShahmoradi, August 31 2024, 6:40 AM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 properties(Access =
public)
34 %> The MATLAB vector of length four containing a set of positive values
35 %> representing the figure pixel coordinates as ``[startx, starty, width, height]`` with respect to the screen.<br>
36 %> The
default value is set such that the whole tiling looks square-shaped.<br>
42 %> The scalar MATLAB ``
struct`` containing the following components:<br>
44 %> <li> ``nrow`` : The MATLAB scalar positive whole-number
45 %> representing the number of subplots in each column of the subplot tiling.<br>
46 %> <li> ``ncol`` : The MATLAB scalar positive whole-number
47 %> representing the number of subplots in each row of the subplot tiling.<br>
48 %> <li> ``tile`` : The scalar MATLAB ``
struct`` containing the following components:<br>
50 %> <li> ``width`` : The MATLAB scalar positive number in the range ``[0, 1]``,
51 %> containing the width of each tile (subplot) along the x-axis
52 %> in normalized units **with respect to the tiling width**.<br>
53 %> The
default value is ``14 / 15``.<br>
54 %> <li> ``height`` : The MATLAB scalar positive number in the range ``[0, 1]``,
55 %> containing the height of each tile (subplot) along the x-axis in normalized units.<br>
56 %> in normalized units **with respect to the tiling height**.<br>
57 %> The
default value is ``14 / 15``.<br>
58 %> <li> ``position`` : The MATLAB tensor of shape ``[4, nrow, ncol]``, each ``[:, irow, icol]``
59 %> slice of
which contains a set of positive normalized values in the range ``[0, 1]``,
60 %> representing the position of the tile sitting at ``[irow, icol]`` starting from
61 %> the top-left corner of the tiling.<br>
62 %> The positions are computed **with respect to the figure container**.<br>
63 %> The position values are calculated based on the tiling position.<br>
64 %> **Beware that
this component is always set by the ``update()`` method.**<br>
66 %> <li> ``position`` : The MATLAB vector of length four containing
67 %> a set of positive normalized values in the range ``[0, 1]``,
68 %> representing the whole tiling coordinates as ``[startx, starty, width, height]``.<br>
69 %> The
default value is ``[0.07, 0.07, 0.93, 0.93]``.<br>
76 %> The MATLAB ``
struct`` containing information about the **horizontal colorbar**
77 %> that can be optionally added to the main axes (i.e., the collection of all axes).<br>
78 %> It has the following components:<br>
81 %> <li> ``position`` : The MATLAB vector of length four containing
82 %> a set of positive normalized values in the range ``[0, 1]``,
83 %> representing the whole colorbar coordinates as ``[startx, starty, width, height]``.<br>
84 %> The
default value is set such that the colorbar sits reasonably at the top of the tiling.<br>
85 %> <li> ``margint`` : The MATLAB scalar positive ``
double`` in the range ``[0, 1]``,
86 %> representing the top margin of the horizontal colorbar that appears on top of the tiling.<br>
87 %> This margin adds room
for adding the colorbar axes label and tick marks.<br>
88 %> The
default value is ``0.07``.<br>
89 %> <li> ``enabled`` : The MATLAB ``logical`` scalar that allows addition of the colorbar
if ``
true``.<br>
90 %> The
default value is ``
false``.<br>
97 %> The MATLAB ``
struct`` containing information about the **horizontal colorbar**
98 %> that can be optionally added to the main axes (i.e., the collection of all axes).<br>
99 %> It has the following components:<br>
102 %> <li> ``position`` : The MATLAB vector of length four containing
103 %> a set of positive normalized values in the range ``[0, 1]``,
104 %> representing the whole colorbar coordinates as ``[startx, starty, width, height]``.<br>
105 %> The
default value is set such that the colorbar sits reasonably at the top of the tiling.<br>
106 %> <li> ``marginr`` : The MATLAB scalar positive ``
double`` in the range ``[0, 1]``,
107 %> representing the top margin of the vertical colorbar that appears to the right of the tiling.<br>
108 %> This margin adds room
for adding the colorbar axes label and tick marks.<br>
109 %> The
default value is ``0.07``.<br>
110 %> <li> ``enabled`` : The MATLAB ``logical`` scalar that allows addition of the colorbar
if ``
true``.<br>
111 %> The
default value is ``
false``.<br>
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119 methods(Access =
public)
121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124 %> Construct and
return an
object of
class [pm.vis.TilingLayout](@ref
TilingLayout).<br>
127 %> This is the constructor of the
class [pm.vis.TilingLayout](@ref
TilingLayout).<br>
129 %> \param[in] nrow : The input scalar MATLAB positive whole-number, containing the number of rows of axes in the tiling.<br>
130 %> \param[in] ncol : The input scalar MATLAB positive whole-number, containing the number of columns of axes in the tiling.<br>
131 %> \param[in] varargin : Any ``property, value`` pair of the parent
object.<br>
132 %> If the
property is a ``
struct()``, then its value must be given as a cell array,
133 %> with consecutive elements representing the
struct ``property-
name, property-value`` pairs.<br>
134 %> Note that all of these property-value pairs can be also directly set via the
135 %> parent
object attributes, before calling the ``make()`` method.<br>
138 %> ``self`` : The output scalar
object of
class [pm.vis.TilingLayout](@ref
TilingLayout).<br>
144 %> g = pm.vis.TilingLayout([], ncol, upper, varargin);
145 %> g = pm.vis.TilingLayout(nrow, [], upper, varargin);
146 %> g = pm.vis.TilingLayout(nrow, ncol, upper, varargin);
158 %> \AmirShahmoradi, August 31 2024, 6:40 AM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
161 self.tiling.ncol = ncol;
162 self.reset(varargin{:});
165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
168 %> Reset the properties of the figure to the original
default settings.<br>
171 %> Use
this method when you change many attributes of the plot and
172 %> you want to
clean up and go back to the
default settings.<br>
174 %> \param[in] self : The **implicitly-passed** input argument representing the parent
object of the method.<br>
175 %> \param[in] varargin : Any ``property, value`` pair of the parent
object.<br>
176 %> If the
property is a ``
struct()``, then its value must be given as a cell array,
177 %> with consecutive elements representing the
struct ``property-
name, property-value`` pairs.<br>
178 %> Note that all of these property-value pairs can be also directly set via the
179 %> parent
object attributes, before calling the ``make()`` method.<br>
184 %> g = pm.vis.TilingLayout(varargin)
185 %> g.reset(varargin); % reset all
object properties to the
default settings.
192 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
193 %> \AmirShahmoradi, July 7 2024, 12:53 AM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
194 function reset(self, varargin)
195 self.tiling.tile =
struct();
196 self.position = nan * zeros(4, 1);
197 self.tiling.position = nan * zeros(4, 1);
198 self.tiling.tile.position = nan * zeros(4, self.tiling.nrow, self.tiling.ncol);
199 self.tiling.tile.height = [];
200 self.tiling.tile.width = [];
201 self.tiling.height = [];
202 self.tiling.width = [];
203 self.cbarh.margint = [];
204 self.cbarv.marginr = [];
205 for cbar = [
"cbarh",
"cbarv"]
206 self.(cbar).enabled = [];
207 self.(cbar).position = [];
209 self.update(varargin{:});
212 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
215 %> Update the figure, tiling, and colorbar layout based on the specified components positions.<br>
218 %> For example, change the tiling or colorbar positions or the tile counts through the relevant
object components,
219 %> then use
this method to renormalize all positions (to range ``[0, 1]``) and update the individual tile positions.<br>
221 %> \param[in] self : The **implicitly-passed** input argument representing the parent
object of the method.<br>
222 %> \param[in] varargin : Any ``property, value`` pair of the parent
object.<br>
223 %> If the property is a ``struct()``, then its value must be given as a cell array,
224 %> with consecutive elements representing the struct ``property-
name, property-value`` pairs.<br>
225 %> Note that all of these property-value pairs can be also directly set via the
226 %> parent
object attributes, before calling the ``make()`` method.<br>
228 %> \interface{update}
231 %> g = pm.vis.TilingLayout(subplot, varargin);
232 %> g.update(varargin);
237 %> This method causes side-effects by manipulating
238 %> the existing attributes of the
object.<br>
245 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
246 %> \AmirShahmoradi, July 7 2024, 12:53 AM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
247 function update(self, varargin)
250 %%%% parse optional arguments.
253 if ~isempty(varargin)
254 self.hash2comp(varargin);
258 %%%% parse optional arguments.
261 for cbar = [
"cbarh",
"cbarv"]
262 if isempty(self.(cbar).enabled)
263 self.(cbar).enabled =
false;
268 %%%% Setup
default tiling dimensions.
271 self.setKeyVal(
"tiling",
"nrow", 1);
272 self.setKeyVal(
"tiling",
"ncol", 1);
273 self.setKeyVal(
"tiling",
"tile",
"width", 14 / 15);
274 self.setKeyVal(
"tiling",
"tile",
"height", 14 / 15);
277 %%%% Setup tiling position.
280 if isnan(self.tiling.position(1)); self.tiling.position(1) = 0.07; end
281 if isnan(self.tiling.position(2)); self.tiling.position(2) = 0.07; end
282 if isnan(self.tiling.position(3)); self.tiling.position(3) = 1 - self.tiling.position(1); end
283 if isnan(self.tiling.position(4)); self.tiling.position(4) = 1 - self.tiling.position(2); end
286 %%%% vertical colorbar specs.
289 def = [ self.tiling.position(1) + self.tiling.position(3) ...
290 , self.tiling.position(2) ...
292 , self.tiling.position(4) - (1 - self.tiling.tile.height) ...
294 if isempty(self.cbarv.position)
295 self.cbarv.position = def;
297 for i = 1 : length(self.cbarv.position)
298 if isnan(self.cbarv.position(i))
299 self.cbarv.position(i) = def(i);
303 if isempty(self.cbarv.marginr) || isnan(self.cbarv.marginr)
304 self.cbarv.marginr = 0.07;
308 %%%% horizontal colorbar specs.
311 def = [ self.tiling.position(1) ...
312 , self.tiling.position(2) + self.tiling.position(4) ...
313 , self.tiling.position(3) - (1 - self.tiling.tile.width) ...
316 if isempty(self.cbarh.position)
317 self.cbarh.position = def;
319 for i = 1 : length(self.cbarh.position)
320 if isnan(self.cbarh.position(i))
321 self.cbarh.position(i) = def(i);
325 if isempty(self.cbarh.margint) || isnan(self.cbarh.margint)
326 self.cbarh.margint = 0.07;
329 normfac = struct("cbarv", 1, "cbarh", 1, "width", 1, "height", 1);
332 %%%% Renormalize positions if colorbars are activated.
335 if self.cbarv.enabled
336 normfac.cbarv = 1 / (self.cbarv.position(1) + self.cbarv.position(3) + self.cbarv.marginr); % last term adds a right margin.
337 self.tiling.position(1) = self.tiling.position(1) * normfac.cbarv;
338 self.tiling.position(3) = self.tiling.position(3) * normfac.cbarv;
339 self.cbarv.position(1) = self.cbarv.position(1) * normfac.cbarv;
340 self.cbarv.position(3) = self.cbarv.position(3) * normfac.cbarv;
341 self.cbarh.position(1) = self.cbarh.position(1) * normfac.cbarv;
342 self.cbarh.position(3) = self.cbarh.position(3) * normfac.cbarv;
345 if self.cbarh.enabled
346 normfac.cbarh = 1 / (self.cbarh.position(2) + self.cbarh.position(4) + self.cbarh.margint); % last term adds a right margin.
347 self.tiling.position(2) = self.tiling.position(2) * normfac.cbarh;
348 self.tiling.position(4) = self.tiling.position(4) * normfac.cbarh;
349 self.cbarh.position(2) = self.cbarh.position(2) * normfac.cbarh;
350 self.cbarh.position(4) = self.cbarh.position(4) * normfac.cbarh;
351 self.cbarv.position(2) = self.cbarv.position(2) * normfac.cbarh;
352 self.cbarv.position(4) = self.cbarv.position(4) * normfac.cbarh;
356 %%%% Set the tile positions.
359 self.tiling.tile.position = zeros(4, self.tiling.nrow, self.tiling.ncol);
360 tile_height_wrt_fig = self.tiling.position(4) / self.tiling.nrow;
361 tile_width_wrt_fig = self.tiling.position(3) / self.tiling.ncol;
362 for icol = 1 : self.tiling.ncol
363 for irow = 1 : self.tiling.nrow
364 jrow = self.tiling.nrow - irow + 1;
365 self.tiling.tile.position(:, irow, icol) = [ self.tiling.position(1) + (icol - 1) * tile_width_wrt_fig ...
366 , self.tiling.position(2) + (jrow - 1) * tile_height_wrt_fig ...
367 , self.tiling.tile.width * tile_width_wrt_fig ...
368 , self.tiling.tile.height * tile_height_wrt_fig ...
374 %%%% Add the missing margin lengths to the colorbar axes.
376 if self.cbarv.enabled
377 self.cbarv.position(4) = self.tiling.position(4) - (1 - self.tiling.tile.height) * tile_height_wrt_fig;
379 if self.cbarh.enabled
380 self.cbarh.position(3) = self.tiling.position(3) - (1 - self.tiling.tile.width) * tile_width_wrt_fig;
384 %%%% Set the figure position.
387 if isempty(self.position) || any(isnan(self.position))
389 self.position = get(0, 'ScreenSize');
390 fig.center = [mean(self.position([1, 3])), mean(self.position([2, 4]))];
391 fig.length = min(self.position(3 : 4)) * .8; % The fraction accounts for padding.
392 if ~self.cbarh.enabled && self.cbarv.enabled
393 normfac.height = normfac.cbarv;
395 if ~self.cbarv.enabled && self.cbarh.enabled
396 normfac.width = normfac.cbarh;
398 fig.width = fig.length * normfac.width;
399 fig.height = fig.length * normfac.height;
400 self.position = [ fig.center(1) - 0.5 * fig.width ...
401 , fig.center(2) - 0.5 * fig.height ...
409 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
413 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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...
function version(in silent)
Return a scalar MATLAB string containing the latest available ParaMonte MATLAB version newer than the...
This is the base class for generating subclass of MATLAB handle superclass whose annoying methods are...
This is the base class for generating instances of objects that contains layout information for a set...
function update(in self, in varargin)
Update the figure, tiling, and colorbar layout based on the specified components positions.
function reset(in self, in varargin)
Reset the properties of the figure to the original default settings.
function TilingLayout(in nrow, in ncol, in varargin)
Construct and return an object of class pm.vis.TilingLayout.
function clean()
Remove all paths that contain the ParaMonte lib directory from the MATLAB path variable.
function release(in type)
Return a scalar MATLAB string containing the MATLAB release version, year, or season as requested.
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...