diverging colormap bwr

ref:http://blog.sciencenet.cn/blog-69686-1160800.html

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/ 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值