关于matlab中的colormap问题

matlab画图后,如果想将不同的值用不同的颜色表示,可以使用colormap这个函数。matlab自带的colormap有很多选项


其中最常用的是第一个,也是默认的选项。那么它是怎么得来的呢?

jet ranges from blue to red, and passes through the colors cyan, yellow, and orange. It is a variation of the hsv colormap. The jet colormap
is associated with an astrophysical fluid jet simulation from the National Center for Supercomputer Applications. 

map=[1 0 0;0 1 0;0 0 1];%三原色
colormap(map)
gray(100)生成100种从黑到白的渐变色,gray(128)生成128色,默认值是256色。如colormap(gray(32))就是32色的灰度色。
在matlab命令行输入cmap=colormap,可以得到当前的色谱
cmap=colormap('jet')


cmap =


         0         0    0.6667
         0         0    1.0000
         0    0.3333    1.0000
         0    0.6667    1.0000
         0    1.0000    1.0000
    0.3333    1.0000    0.6667
    0.6667    1.0000    0.3333
    1.0000    1.0000         0
    1.0000    0.6667         0
    1.0000    0.3333         0

即将峰值pv值平均分配到colorbar中,相应的颜色代表相应数值

 map1 = colormap('jet')

map1 =

         0         0    0.5625          0         0    0.6250          0         0    0.6875          0         0    0.7500          0         0    0.8125          0         0    0.8750          0         0    0.9375          0         0    1.0000          0    0.0625    1.0000          0    0.1250    1.0000          0    0.1875    1.0000          0    0.2500    1.0000          0    0.3125    1.0000          0    0.3750    1.0000          0    0.4375    1.0000          0    0.5000    1.0000          0    0.5625    1.0000          0    0.6250    1.0000          0    0.6875    1.0000          0    0.7500    1.0000          0    0.8125    1.0000          0    0.8750    1.0000          0    0.9375    1.0000          0    1.0000    1.0000     0.0625    1.0000    0.9375     0.1250    1.0000    0.8750     0.1875    1.0000    0.8125     0.2500    1.0000    0.7500     0.3125    1.0000    0.6875     0.3750    1.0000    0.6250     0.4375    1.0000    0.5625     0.5000    1.0000    0.5000     0.5625    1.0000    0.4375     0.6250    1.0000    0.3750     0.6875    1.0000    0.3125     0.7500    1.0000    0.2500     0.8125    1.0000    0.1875     0.8750    1.0000    0.1250     0.9375    1.0000    0.0625     1.0000    1.0000         0     1.0000    0.9375         0     1.0000    0.8750         0     1.0000    0.8125         0     1.0000    0.7500         0     1.0000    0.6875         0     1.0000    0.6250         0     1.0000    0.5625         0     1.0000    0.5000         0     1.0000    0.4375         0     1.0000    0.3750         0     1.0000    0.3125         0     1.0000    0.2500         0     1.0000    0.1875         0     1.0000    0.1250         0     1.0000    0.0625         0     1.0000         0         0     0.9375         0         0     0.8750         0         0     0.8125         0         0     0.7500         0         0     0.6875         0         0     0.6250         0         0     0.5625         0         0     0.5000         0         0


  • 7
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Matlabcolormap是用于设置图像或图表的颜色映射的函数。它的输入可以是一个包含任意行,但只有三列的矩阵(n*3)。矩阵的每一行代表一种颜色,其三个数字分别对应红(R)、绿(G)、蓝(B)三个颜色通道的强度值(范围为0-1)。通过改变这三个通道值的强度,我们可以映射出所需的各种颜色。例如,(0,0,0)代表黑色,(1,1,1)代表白色。 在绘制图像或图表后,使用colormap函数可以改变其颜色。你可以使用内置的颜色表,也可以自定义颜色表。内置的颜色表包括常见的颜色映射,例如parula、jet、hsv等。这些颜色表可以通过colormap函数直接调用。例如,colormap(jet)将使用jet颜色表来映射图像或图表的颜色。 如果你想自定义颜色表,可以创建一个自定义的n*3矩阵,其每一行代表一种颜色,然后使用colormap函数将其设置为当前的颜色映射。例如,你可以使用下面的代码创建一个自定义颜色表并将其应用于图像: ```matlab mycmp = [0 0 0; 0.17 0.54 0.29; 0.5 0.78 0.5; 0.78 1 0.6; 1 1 0.71; 1 0.82 0.39; 1 0.57 0.25; 1 0 0; 0.7 0 0.16; 0.4 0 0.25; 0.11 0.011 0.32]; aa = rand(10, 10); figure; imagesc(aa); colormap(mycmp); colorbar; title('自定义颜色表'); ``` 以上代码创建了一个自定义颜色表mycmp,并将其应用于一个随机生成的10x10图像。使用colormap函数将mycmp设置为当前的颜色映射,然后使用imagesc函数绘制图像。最后,使用colorbar函数添加一个颜色条,并使用title函数添加标题。 除了图像,colormap函数还可以应用于其他类型的图表,如表面图(surf)。你可以使用类似的方法将自定义颜色表应用于表面图。 希望这可以帮到你!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Matlab如何定义和使用colormap?|colormap的使用](https://blog.csdn.net/qq_38941890/article/details/124505928)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [Matlab函数解释:colormap](https://blog.csdn.net/lvsehaiyang1993/article/details/80353177)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值