2%> This is the abstract
class for generating instances of objects
3%> that contain the specifications of a cascade of figures (plots).<br>
6%> This is a
generic class for generating multiple separate
7%> cascading figures each containing a single plot (axes).<br>
10%> While dynamic addition of
class attributes is not ideal, the current
11%> design was deemed unavoidable and best, given the constraints of the
12%> MATLAB language and visualization tools.<br>
15%> See the
list of
class attributes below,
16%> also those of the superclass [pm.matlab.Handle](@ref
Handle).<br>
19%> [pm.vis.Cascade](@ref
Cascade)<br>
20%> [pm.vis.Subplot](@ref
Subplot)<br>
21%> [pm.vis.Triplex](@ref
Triplex)<br>
22%> [pm.vis.Figure](@ref
Figure)<br>
23%> [pm.vis.Plot](@ref
Plot)<br>
24%> [pm.vis.Tile](@ref
Tile)<br>
29%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
30%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 properties(Access =
public)
39 %> The cell array of scalar objects of superclass [pm.vis.Plot](@ref
Plot)
40 %> representing the cascade of plots to display.<br>
46 %> The scalar
object of superclass [pm.vis.Plot](@ref
Plot)
47 %> representing the
template of the cascade of plots to display.<br>
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 methods(Access =
public)
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 %> Construct and
return an
object of
class [pm.vis.Cascade](@ref
Cascade).<br>
62 %> This is the custom constructor of the
class [pm.vis.Cascade](@ref
Cascade).<br>
64 %> \param[in] template : The input scalar
object of superclass [pm.vis.Plot](@ref
Plot).<br>
65 %> It serves as the
template based upon
which the cascade of plots are constructed.<br>
66 %> \param[in] varargin : Any ``property, value`` pair of the parent
object.<br>
67 %> If the property is a ``
struct()``, then its value must be given as a cell array,
68 %> with consecutive elements representing the
struct ``property-
name, property-value`` pairs.<br>
69 %> Note that all of these
property-value pairs can be also directly set via the
70 %> parent
object attributes, before calling the [pm.vis.Cascade.make()](@ref
Cascade::make) method.<br>
73 %> ``self`` : The scalar output
object of
class [pm.vis.Cascade](@ref
Cascade).<br>
78 %> plot = pm.vis.
Cascade(
template);
79 %> plot = pm.vis.Cascade(
template, varargin);
84 %> The input ``varargin`` can also contain the components
85 %> of the ``plot`` component of the parent
object.<br>
88 %> \include{lineno} example/vis/
Cascade/main.m
97 %> \JoshuaOsborne, May 21 2024, 6:20 AM, University of Texas at Arlington<br>
98 %> \AmirShahmoradi, July 5 2024, 1:07 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
99 function self =
Cascade(
template, varargin)
101 self.reset(varargin{:});
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 %> Reset the properties of the cascade of plots to the original
default settings.<br>
110 %> Use
this method when you change many attributes of the plot and
111 %> you want to
clean up and go back to the
default settings.<br>
113 %> \param[inout] self : The input/output parent
object of
class [pm.vis.Cascade](@ref
Cascade)
114 %>
which is **implicitly** passed to
this dynamic method (not by the user).<br>
115 %> \param[in] varargin : Any ``property, value`` pair of the parent
object.<br>
116 %> If the
property is a ``
struct()``, then its value must be given as a cell array,
117 %> with consecutive elements representing the
struct ``property-
name, property-value`` pairs.<br>
118 %> Note that all of these property-value pairs can be also directly set via the
119 %> parent
object attributes, before calling the [pm.vis.Cascade.make()](@ref
Cascade::make) method.<br>
122 %> The input ``varargin`` can also contain the components
123 %> of the ``
template`` component of the parent
object.
128 %> pm.vis.Cascade.reset() % reset the plot to the
default settings.
129 %> pm.vis.Cascade.reset(varargin) % reset the plot to the
default settings and to those specified via ``varargin``.
136 %> \JoshuaOsborne, May 21 2024, 6:25 AM, University of Texas at Arlington<br>
137 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
138 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
139 function reset(self, varargin)
141 if ~isempty(varargin)
142 [varpar, varsub] = pm.matlab.hashmap.popKeyVal([
"template",
"window"], varargin);
144 self.hash2comp(varpar);
147 self.template.reset(varsub{:});
151 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
152 %%%% RULE 0: Any non-MATLAB-
default setting must be preferably set in premake() method to override user null values.
153 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
160 %> Configure the cascade settings and specifications,
161 %> make the cascade of plots, and return nothing.<br>
164 %> In making the figure, this method calls the ``make()``
165 %> methods of each of the plot objects stored in the
166 %> ``window`` component.<br>
169 %> This method has side-effects by manipulating
170 %> the existing attributes of the parent
object.<br>
172 %> \param[inout] self : The input/output parent
object of class [pm.vis.
Cascade](@ref
Cascade)
173 %>
which is **implicitly** passed to this dynamic method (not by the user).<br>
174 %> \param[in] varargin : Any ``property, value`` pair of the parent
object.<br>
175 %> If the property is a ``struct()``, then its value must be given as a cell array,
176 %> with consecutive elements representing the struct ``property-
name, property-value`` pairs.<br>
177 %> Note that all of these property-value pairs can be also directly set via the parent
object attributes,
178 %> before calling the [pm.vis.
Cascade.make()](@ref
Cascade::make) method.<br>
183 %> p = pm.vis.Cascade.make(varargin);
188 %> The input ``varargin`` can also contain the components
189 %> of the ``
template`` component of the parent
object.<br>
192 %> \include{lineno} example/vis/
Cascade/main.m
201 %> \JoshuaOsborne, May 21 2024, 6:27 AM, University of Texas at Arlington<br>
202 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
203 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
204 function make(self, varargin)
206 self.premake(varargin{:});
208 %%%% First set the cascade dimensions.
210 isHeatmap = isa(self.template,
"pm.vis.PlotHeatmap");
211 isEllipsoid = isa(self.template,
"pm.vis.PlotEllipse") || isa(self.template,
"pm.vis.PlotEllipse3");
215 %%%% Set the data
for the Heatmap.
218 hdf.colx = self.template.subplot.colx;
219 hdf.rows = self.template.subplot.rows;
220 if ~iscell(self.template.subplot.colx) && ~isempty(self.template.subplot.colx)
221 hdf.colx = {hdf.colx};
223 if ~iscell(self.template.subplot.rows) && ~isempty(self.template.subplot.rows)
224 hdf.rows = {hdf.rows};
227 %%%% Test the data size consistency.
229 nplt = max(numel(hdf.colx), numel(hdf.rows));
230 if (nplt ~= size(self.template.subplot.rows, 1) && size(self.template.subplot.rows, 1) > 1) ...
231 || (nplt ~= size(self.template.subplot.colx, 1) && size(self.template.subplot.colx, 1) > 1)
232 help(
"pm.vis.CascadeHeatmap");
233 disp(
"size(self.template.subplot.rows)");
234 disp( size(self.template.subplot.rows) );
235 disp(
"size(self.template.subplot.colx)");
236 disp( size(self.template.subplot.colx) );
238 +
"The size of the ``rows`` and ``colx`` attributes of the ``subplot`` component" + newline ...
239 +
"of the input template ``Plot`` object must equal along the first dimension." + newline ...
240 +
"For more information, see the documentation displayed above." + newline ...
247 nplt = max([1, numel(self.template.subplot.dimx), numel(self.template.subplot.dimy)]);
252 if isprop(self.template.subplot,
"colx")
253 lencolx = pm.array.
len(self.template.subplot.colx);
257 if isprop(self.template.subplot, "coly")
258 lencoly = pm.array.
len(self.template.subplot.coly);
262 if isprop(self.template.subplot, "colz")
263 lencolz = pm.array.
len(self.template.subplot.colz);
267 if isprop(self.template.subplot, "colc")
268 lencolc = pm.array.
len(self.template.subplot.colc);
271 nplt = max([lencolx, lencoly, lencolz, lencolc]);
275 %%%% Define the cascade.
276 %%%% The following code block may be improved in
277 %%%% the future to avoid full data
copy to subplots.
279 self.window = cell(nplt, 1);
281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282 %%%% The
byte stream approach leads to serious problems with
283 %%%% figures when generated from within sampler components.
284 %byteStream = getByteStreamFromArray(self.template);
285 %self.window{iplt} = getArrayFromByteStream(byteStream);
286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
287 self.window{iplt} = pm.matlab.copy(self.template, eval(
string(
class(self.template)) +
"()"));
288 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
290 if ~isempty(hdf.colx)
291 self.window{iplt}.subplot.colx = hdf.colx{min(iplt, numel(hdf.colx))};
293 if ~isempty(hdf.rows)
294 self.window{iplt}.subplot.rows = hdf.rows{min(iplt, numel(hdf.rows))};
297 if ~isempty(self.template.subplot.dimx)
298 self.window{iplt}.subplot.dimx = self.template.subplot.dimx(min(iplt, numel(self.template.subplot.dimx)));
300 if ~isempty(self.template.subplot.dimy)
301 self.window{iplt}.subplot.dimy = self.template.subplot.dimy(min(iplt, numel(self.template.subplot.dimy)));
305 self.window{iplt}.subplot.colx = self.template.subplot.colx(iplt);
308 self.window{iplt}.subplot.coly = self.template.subplot.coly(iplt);
311 self.window{iplt}.subplot.colz = self.template.subplot.colz(iplt);
314 self.window{iplt}.subplot.colc = self.template.subplot.colc(iplt);
317 self.window{iplt}.make();
322 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
325 %> Export the current cascade of figures to the specified external files.<br>
328 %> This method is merely a wrapper around
329 %> all ``
savefig`` methods of the figure objects in
330 %> the ``window`` component of the parent cascade
object.<br>
332 %> \param[inout] self : The input/output parent
object of
class [pm.vis.Cascade](@ref
Cascade)
333 %>
which is **implicitly** passed to
this dynamic method (not by the user).<br>
334 %> \param[in] file : The input **vector** of MATLAB strings or cell array of
char vectors
335 %> containing the paths to the external output figure files.<br>
336 %> It must be of the same length as the ``window`` component of the parent
object.<br>
337 %> For more information, see the corresponding argument ``file`` of the ``
savefig``
338 %> method of
class [pm.vis.figure.Figure](@ref
Figure).<br>
339 %> (**optional**. If ``file`` or any elements of it is missing or empty,
340 %> the
default will be set by the ``
savefig`` method of the corresponding
341 %> cascade figure in the ``window`` component.)
343 %> \param[in] varargin : Any optional key-val pair that is accepted by
344 %> the ``
savefig`` method of
class [pm.vis.figure.Figure](@ref
Figure).<br>
345 %> For more information, see the ``
savefig`` method of
class [pm.vis.figure.Figure](@ref
Figure).<br>
352 %> c.savefig(file, varargin);
357 %> \include{lineno} example/vis/
Cascade/main.m
366 %> \JoshuaOsborne, May 21 2024, 6:29 AM, University of Texas at Arlington<br>
367 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
368 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
369 function
savefig(self, file, varargin)
370 % deleted doc
for ``file`` behavior:
373 % <li> of the same length as the ``window`` component of the parent object, or,<br>
374 % <li> scalar
string or vector of length one.<br>
375 % If so, the specified single value
for ``file`` will be used a prefix
376 %
for all output figures and each figure will be suffixed with ``.i.png``
377 % where ``i`` is replaced with the figure number starting from ``1``.<br>
378 % **Beware that any existing figure file with the same
name will be overwritten.**<br>
380 if nargin < 2 || isempty(file)
381 file = strings(numel(self.window), 1);
383 if numel(file) ~= numel(self.window)
385 disp("numel(self.window)");
386 disp( numel(self.window) );
390 + "The condition ``numel(file) == numel(self.window)`` must hold." + newline ...
391 + "For more information, see the documentation displayed above." + newline ...
396 %%%% Starting from the last is important
397 %%%% to ensure all figures have been already created,
398 %%%% otherwise, the next figure to be generate will
399 %%%% become active over the previous images that
400 %%%% are being saved, corrupting the export.
403 %%%% Assuming all figures are generated sequentially from the first to the last,
404 %%%% the following fix to export figures from the last to the first should work.
405 %%%% However, this is only a temporary fix. An ideal solution must ensure all
406 %%%% figures have been generated before starting to export any figure.
408 for iwin = numel(self.window) : -1 : 1
409 self.window{iwin}.savefig(file(iwin), varargin{:});
413 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
419 methods(Access =
public, Hidden)
421 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
424 %> Configure the cascade of plots settings and specifications and
return nothing.<br>
427 %> This method has side-effects by manipulating
428 %> the existing attributes of the parent
object.<br>
430 %> \param[inout] self : The input/output parent
object of
class [pm.vis.Cascade](@ref
Cascade)
431 %>
which is **implicitly** passed to
this dynamic method (not by the user).<br>
432 %> \param[in] varargin : Any ``property, value`` pair of the parent
object.<br>
433 %> If the
property is a ``
struct()``, then its value must be given as a cell array,
434 %> with consecutive elements representing the
struct ``property-
name, property-value`` pairs.<br>
435 %> Note that all of these property-value pairs can be also directly set via the
436 %> parent
object attributes, before calling the ``premake()`` method.<br>
438 %> \interface{premake}
441 %> c = pm.vis.Cascade.premake(varargin);
448 %> cv = pm.vis.Cascade(pm.vis.PlotLine(rand(100, 10)));
449 %> c.premake(
"figure", {
"color",
"white"})
450 %> cv.make(
"coly", 1:3)
457 %> \JoshuaOsborne, May 21 2024, 6:31 AM, University of Texas at Arlington<br>
458 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
459 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
460 function premake(self, varargin)
462 if ~isempty(varargin)
463 [varpar, varsub] = pm.matlab.hashmap.popKeyVal([
"template",
"window"], varargin);
465 self.hash2comp(varpar);
468 self.template.premake(varsub{:});
472 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
473 %%%% These settings must happen here so that they can be reset every time user nullifies the values.
474 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
478 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
482 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 a c...
function make(in self, in varargin)
Configure the cascade settings and specifications, make the cascade of plots, and return nothing.
function premake(in self, in varargin)
Configure the cascade of plots settings and specifications and return nothing.
function reset(in self, in varargin)
Reset the properties of the cascade of plots to the original default settings.
function savefig(in self, in file, in varargin)
Export the current cascade of figures to the specified external files.
function Cascade(in template, in varargin)
Construct and return an object of class pm.vis.Cascade.
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 contain the specifications of various...
This is the abstract class for generating instances of axes with various types of plots from one or m...
This is the abstract class for generating instances of objects that contain the specifications of var...
This is the base class for generating instances of figures containing a square symmetric tiling of su...
function clean()
Remove all paths that contain the ParaMonte lib directory from the MATLAB path variable.
function copy(in from, in to, in field, in exclude)
Copy the contents of the struct/object from to the struct/object to recursively and without destroyin...
function len(in obj)
Return a scalar MATLAB whole-number containing the length of the input scalar or vector object.
function savefig(in varargin)
Export figures in a publication-quality format.
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...