matlab表面图的自定义颜色 [英] Custom colour for matlab surface plot

查看:1213
本文介绍了matlab表面图的自定义颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经加载了一些地形数据到matlab,并创建了这些数据的surf,surfl和等值线图,使用颜色映射着色。

I have loaded in some topographic data to matlab, and created surf, surfl and contour plots of this data, colouring them using colormap. The topographic data ranges from 0 to 2500 m.

我想绘制一幅地图,使任何地形在200米以下,500米以上,200到500之间m绿色。有可能做到这一点吗?

I want to plot a map that colours any topography below 200 m blue, above 500 m red, and between 200 and 500 m green. Is it possible to do this? Could anyone give me any tips regarding the command required to do so?

非常感谢

推荐答案

您可以使用 colormap surf 的第四个输入进行播放。

You may play with colormap and the fourth input of 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])

这篇关于matlab表面图的自定义颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆