由于您只想将圆圈区域设置为单一颜色,您可以设置它的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')
编辑
如果您想为您的部分表面设置不同的颜色图,您需要将'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])