ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
redblue.m
Go to the documentation of this file.
1%> \brief
2%> Return a blue-red colormap matrix
3%> of shape ``(nell, 3)`` containing a **redblue** colormap.<br>
4%>
5%> \details
6%> The colors begin with bright blue, range through shades of
7%> blue to white, and then through shades of red to bright red.<br>
8%> The output is the same length as the current figure colormap.<br>
9%> If no figure exists, MATLAB will create one.<br>
10%>
11%> \param[in] nell : The input scalar MATLAB integer representing
12%> the number of elements (rows) of the output colormap matrix.<br>
13%> (**optional**, default = ``size(get(gcf, 'colormap'), 1)``)
14%>
15%> \return
16%> ``cmap`` : The output blue-red colormap matrix
17%> of shape ``[nell, 3]`` containing a **redblue** colormap.<br>
18%>
19%> \interface{redblue}
20%> \code{.m}
21%>
22%> cmap = pm.vis.cmap.redblue()
23%> cmap = pm.vis.cmap.redblue([])
24%> cmap = pm.vis.cmap.redblue(nell)
25%>
26%> \endcode
27%>
28%> \example{redblue}
29%> \include{lineno} example/vis/cmap/redblue/main.m
30%> \vis{redblue}
31%> \image html example/vis/cmap/redblue/redblue.1.png width=700
32%> \image html example/vis/cmap/redblue/redblue.2.png width=700
33%>
34%> \see
35%> MATLAB intrinsic functions ``hsv()``, ``gray()``, ``hot()``, ``bone()``, ``copper()``, ``pink()``, ``flag()``, ``colormap()``, ``rgbplot()``.<br>
36%>
37%> \final{redblue}
38%>
39%> Adam Auton, 9th October 2009
40%> Copyright (c) 2009, Adam Auton
41%> All rights reserved.
42%>
43%> Redistribution and use in source and binary forms, with or without
44%> modification, are permitted provided that the following conditions are
45%> met:
46%>
47%> * Redistributions of source code must retain the above copyright
48%> notice, this list of conditions and the following disclaimer.
49%> * Redistributions in binary form must reproduce the above copyright
50%> notice, this list of conditions and the following disclaimer in
51%> the documentation and/or other materials provided with the distribution
52%>
53%> This software is provided by the copyright holders and contributors "as is"
54%> and any express or implied warranties, including, but not limited to, the
55%> implied warranties of merchantability and fitness for a particular purpose
56%> are disclaimed. in no event shall the copyright owner or contributors be
57%> liable for any direct, indirect, incidental, special, exemplary, or
58%> consequential damages (including, but not limited to, procurement of
59%> substitute goods or services; loss of use, data, or profits; or business
60%> interruption) however caused and on any theory of liability, whether in
61%> contract, strict liability, or tort (including negligence or otherwise)
62%> arising in any way out of the use of this software, even if advised of the
63%> possibility of such damage.
64%>
65%> \author
66%> \JoshuaOsborne, May 21 2024, 7:44 AM, University of Texas at Arlington<br>
67%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
68%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
69function cmap = redblue(nell)
70 if nargin < 1
71 nell = size(get(gcf, 'colormap'), 1);
72 end
73 if (mod(nell, 2) == 0)
74 % From [0 0 1] to [1 1 1], then [1 1 1] to [1 0 0];
75 nellHalf = nell * 0.5;
76 r = (0 : nellHalf - 1)' / max(nellHalf - 1, 1);
77 g = r;
78 r = [r; ones(nellHalf, 1)];
79 g = [g; flipud(g)];
80 b = flipud(r);
81 else
82 % From [0 0 1] to [1 1 1] to [1 0 0];
83 nellHalf = floor(nell * 0.5);
84 r = (0 : nellHalf - 1)' / max(nellHalf, 1);
85 g = r;
86 r = [r; ones(nellHalf + 1, 1)];
87 g = [g; 1; flipud(g)];
88 b = flipud(r);
89 end
90 cmap = [r, g, b];
91end
function list()
Return a list of MATLAB strings containing the names of OS platforms supported by the ParaMonte MATLA...
function redblue(in nell)
Return a blue-red colormap matrix of shape (nell, 3) containing a redblue colormap.