使用不同配色方案的Matlab冲浪

Fan*_*Fox 5 matlab visualization

我有一个地形图,我想表示一些数据.见下图:

在此输入图像描述

右边的区域由白色圈出,是与场地其余部分分开的冲浪功能.我希望能够做的是改变配色方案.外部应该是灰度级,内部应该是基于我与绘图分开的值的单一颜色.目前我已经尝试了色彩映射(灰色)功能然后改变,但这改变了整个情节.

我对有关不同绘图风格的建议持开放态度.plot3而不是冲浪.因此,我必须制作这两个冲浪的数据是x,y,z点的两个列表.

如果可能的话,我还想显示一个颜色条,它代表圆圈区域的颜色(由我根据外部值设置).

有谁知道这样做的好方法?

谢谢.

编辑:

我想做的是:

在此输入图像描述

图像的顶部不应有深蓝色.图像将随着更多的"蓝色"斑点不断更新,颜色应根据外部值进行更改,理想情况下,如果颜色重叠,它会将颜色与之前的点合并.

Jon*_*nas 7

由于您只想将带圆圈的区域设置为单一颜色,因此可以设置它的FaceColor属性.例如:

%# make some test data
[xx,yy]=ndgrid(-5:0.1:5,-5:0.1:5);
zz = exp(-xx.^2/2+-yy.^2/2);
zz1 = zz;
zz1(zz1>0.5)=NaN;
zz2 = zz;
zz2(zz2<0.5)=NaN;

%# plot first surface, set colormap
surf(zz1)
colormap('gray')

%# stretch colormap to [0 0.5]
caxis([0 0.5])

%# plot the second surface in red
hold on
surf(zz2,'faceColor','r')
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

编辑

如果要为曲面的某些部分设置不同的颜色映射,则需要'CData'将曲面的属性设置为颜色映射中的索引.要仅在颜色栏中显示单个色彩图,您可以利用色条只是另一个图的事实,这意味着您只能显示其中的一部分,并更改标签.

%# make some more test data
[xx,yy]=ndgrid(-5:0.1:5,-5:0.1:5);
zz = exp(-xx.^2/2+-yy.^2/2);
zz1 = zz(1:50,:);
zz2 = zz(52:end,:);
xx1 = xx(1:50,:);xx2=xx(52:end,:);
yy1 = yy(1:50,:);yy2=yy(52:end,:);

%# create multi-colormap, set it to figure
figure
cmap = [gray(128);copper(128)];
colormap(cmap)

%# plot surfaces, setting the cdata property to indices 1-128 and 129-256, 
%# respectively, in order to access the different halves of the colormap
surf(xx1,yy1,zz1,'cdata',round(127*(zz1-min(zz1(:))/(max(zz1(:))-min(zz1(:)))))+1,'cdatamapping','direct')
hold on
surf(xx2,yy2,zz2,'cdata',round(127*(zz2-min(zz2(:))/(max(zz2(:))-min(zz2(:)))))+129,'cdatamapping','direct')

%# find the handle to the colorbar
%# alteratively: cbarH = findall(gcf,'tag','Colorbar')
cbarH = colorbar;

%# set limits and ticks/labels
ylim(cbarH,[129 255])
set(cbarH,'ytick',[129 192 255],'yticklabel',[0 0.5 1])
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


kit*_*tte 2

您是否从 MATLAB 技术支持处看到过此信息?

http://www.mathworks.com/support/solutions/en/data/1-GNRWEH/index.html

您可以编辑colorbar属性。

g = colorbar;
get(g)
Run Code Online (Sandbox Code Playgroud)

例如,

% Define a colormap that uses the cool colormap and 
% the gray colormap and assign it as the Figure's colormap.
colormap([cool(64);gray(64)])


% Generate some surface data.
[X,Y,Z] = peaks(30);


% Produce the two surface plots.
h(1) = surf(X,Y,Z);
hold on
h(2) = pcolor(X,Y,Z);
hold off


% Move the pcolor to Z = -10.
% The 0*Z is in the statement below to insure that the size
% of the ZData does not change.
set(h(2),'ZData',-10 + 0*Z)
set(h(2),'FaceColor','interp','EdgeColor','interp')
view(3)


% Scale the CData (Color Data) of each plot so that the 
% plots have contiguous, nonoverlapping values. The range 
% of each CData should be equal. Here the CDatas are mapped 
% to integer values so that they are easier to manage; 
% however, this is not necessary.


% Initially, both CDatas are equal to Z.
m = 64; % 64-elements is each colormap


cmin = min(Z(:));
cmax = max(Z(:));
% CData for surface
C1 = min(m,round((m-1)*(Z-cmin)/(cmax-cmin))+1); 
% CData for pcolor
C2 = 64+C1;


% Update the CDatas for each object.
set(h(1),'CData',C1);
set(h(2),'CData',C2);


% Change the CLim property of axes so that it spans the 
% CDatas of both objects.
caxis([min(C1(:)) max(C2(:))])

% I added these two lines
g = colorbar
set(g,'YLim',[1 60])
Run Code Online (Sandbox Code Playgroud)

最后两行是我的。其余部分来自 MATLAB 技术支持链接。它会给你一个只有一个颜色图的颜色条。如果您想要颜色图的灰色一半,那么您就可以这样做set(g,'YLim',[64 128])

在此输入图像描述