【源码】红蓝配色图——从亮蓝色到白色再到亮红色
REDBLUE(M)是一个M x 3的矩阵,它定义了一种颜色映射关系。

REDBLUE(M), is an M-by-3 matrix that defines a colormap.

颜色变化从亮蓝色开始,范围从蓝色到白色,然后从红色到亮红色。

The colors begin with bright blue, range through shades of blue to white, and then through shades of red to bright red.

function c = redblue(m)

%REDBLUE Shades of red and blue color map

% REDBLUE(M), is an M-by-3 matrix that defines a colormap.

% The colors begin with bright blue, range through shades of

% blue to white, and then through shades of red to bright red.

% REDBLUE, by itself, is the same length as the current figure’s

% colormap. If no figure exists, MATLAB creates one.

%

% For example, to reset the colormap of the current figure:

%

% colormap(redblue)

%

% See also HSV, GRAY, HOT, BONE, COPPER, PINK, FLAG,

% COLORMAP, RGBPLOT.

% Adam Auton, 9th October 2009

if nargin < 1, m = size(get(gcf,‘colormap’),1); end

if (mod(m,2) == 0)

% From [0 0 1] to [1 1 1], then [1 1 1] to [1 0 0];

m1 = m*0.5;

r = (0:m1-1)'/max(m1-1,1);

g = r;

r = [r; ones(m1,1)];

g = [g; flipud(g)];

b = flipud(r);

else

% From [0 0 1] to [1 1 1] to [1 0 0];

m1 = floor(m*0.5);

r = (0:m1-1)'/max(m1,1);

g = r;

r = [r; ones(m1+1,1)];

g = [g; 1; flipud(g)];

b = flipud(r);

end

c = [r g b];

源码下载地址:

http://page2.dfpan.com/fs/blcfj2521029e16a0b4/

更多精彩文章请关注微信号:【源码】红蓝配色图——从亮蓝色到白色再到亮红色

相关文章: