自定义颜色为matlab表面图

use*_*970 4 matlab command colors map contour

我已经将一些地形数据加载到matlab,并创建了这些数据的冲浪,冲浪和等高线图,使用colormap对它们进行着色.地形数据范围从0到2500米.

我想绘制一张地图,颜色为200米以下,500米以上,200至500米绿色以下的任何地形.是否有可能做到这一点?任何人都可以给我任何关于命令所需的提示吗?

非常感谢

mar*_*sei 6

你可以玩colormap和第四个输入surf.

以下情节

在此输入图像描述

由...产生

[X,Y,Z] = peaks(1000);

%colormap
cmap = [0.6 0.2 0.4; 
        0.5 0.5 0.5; 
        0.1 0.9 0.9];  

Zcolor = zeros(size(Z));                   
threshold = 2;
Zcolor(Z <= -threshold)                 = 1;  % first row of cmap
Zcolor(Z > -threshold & Z < threshold)  = 2;  % second row of cmap
Zcolor(Z >= threshold)                  = 3;  % third row of cmap

figure('Color','w');
surf(X, Y, Z, Zcolor, 'EdgeColor', 'None');
colormap(cmap); 
light('Position', [0 -2 1])
Run Code Online (Sandbox Code Playgroud)