yaozhixiong的个人博客分享 http://blog.sciencenet.cn/u/yaozhixiong

博文

matlab 造 colorbar

已有 6032 次阅读 2013-1-2 19:44 |个人分类:matlab|系统分类:科研笔记|关键词:学者| MATLAB, colorbar


% -------------------------------------
bb(1:20,1)=ones(20,1);
gg(12:20,1)=ones(9,1);
gg(1:11,1)=(linspace(0,1,11))';
rr(10:20,1)=(linspace(0,1,11))';
rr(1:9,1)=zeros(9,1);
rr(21:40,1)=ones(20,1);
gg(21:29,1)=ones(9,1);
gg(30:40,1)=(linspace(1,0,11))';
bb(21:31,1)=(linspace(1,0,11))';
bb(32:40,1)=zeros(9,1);
cc=[rr,gg,bb];colormap(cc);
% -------------------------------------
figure;colorbar;colormap(cc);

colormap 是40行3列的矩阵,可以调整范围,存储以方便调用。

        0         0    1.0000
        0    0.1000    1.0000
        0    0.2000    1.0000
        0    0.3000    1.0000
        0    0.4000    1.0000
        0    0.5000    1.0000
        0    0.6000    1.0000
        0    0.7000    1.0000
        0    0.8000    1.0000
        0    0.9000    1.0000
   0.1000    1.0000    1.0000
   0.2000    1.0000    1.0000
   0.3000    1.0000    1.0000
   0.4000    1.0000    1.0000
   0.5000    1.0000    1.0000
   0.6000    1.0000    1.0000
   0.7000    1.0000    1.0000
   0.8000    1.0000    1.0000
   0.9000    1.0000    1.0000
   1.0000    1.0000    1.0000
   1.0000    1.0000    1.0000
   1.0000    1.0000    0.9000
   1.0000    1.0000    0.8000
   1.0000    1.0000    0.7000
   1.0000    1.0000    0.6000
   1.0000    1.0000    0.5000
   1.0000    1.0000    0.4000
   1.0000    1.0000    0.3000
   1.0000    1.0000    0.2000
   1.0000    1.0000    0.1000
   1.0000    0.9000         0
   1.0000    0.8000         0
   1.0000    0.7000         0
   1.0000    0.6000         0
   1.0000    0.5000         0
   1.0000    0.4000         0
   1.0000    0.3000         0
   1.0000    0.2000         0
   1.0000    0.1000         0
   1.0000         0         0



另外,网上有帖子“盗取他人colorbar”,也可以参考下。




2013.03.12

增加一个常用colorbar,要注意设置,caxis([-a,a])



BlWhRe.txt





https://m.sciencenet.cn/blog-419857-648946.html

上一篇:Microsoft visual studio 2008 + Intel.Visual.Fortran.Compiler
下一篇:Windows平台上NCL的安装

1 杨华磊

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

数据加载中...

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

GMT+8, 2024-6-2 12:16

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部