大工至善|大学至真分享 http://blog.sciencenet.cn/u/lcj2212916

博文

[转载]【源码】红蓝配色图——从亮蓝色到白色再到亮红色

已有 2804 次阅读 2019-2-5 11:15 |系统分类:科研笔记|文章来源:转载


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/ 


更多精彩文章请关注微信号:qrcode_for_gh_60b944f6c215_258.jpg




https://blog.sciencenet.cn/blog-69686-1160800.html

上一篇:[转载]【机器学习开放项目】教育数据挖掘
下一篇:[转载]【新书推荐】【2018.10】驾考秘籍电子彩版书(胡和平著)
收藏 IP: 183.160.73.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-9-20 23:31

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部