不同配色方案的 Matlab 冲浪

标签 matlab visualization

我有一张地形图,我想在其中表示一些数据。请参见下图:

enter image description here

右侧用白色圈出的区域是独立于绘图其余部分的冲浪功能。我希望能够做的是改变配色方案。外部应该是灰度,内部应该是基于我与绘图分开的值的单一颜色。目前我已经尝试了 colormap(gray) 函数然后改变但是改变了整个情节。

我愿意接受有关不同绘图风格的建议,即。 plot3 而不是冲浪。因此,我必须进行这两次冲浪的数据是 x、y、z 点的两个列表。

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

有人知道这样做的好方法吗?

谢谢。

编辑:

我想做的是:

enter image description here

图像在土墩顶部不应有深蓝色。图像将不断更新更多“蓝色”点,颜色应根据外部值发生变化,理想情况下,如果它们重叠,它将与之前的点合并颜色。

最佳答案

因为您只想将圆圈区域设置为单一颜色,您可以设置它的 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')

enter image description here

编辑

如果您想为表面的各个部分使用不同的颜色图,则需要将表面的 '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])

enter image description here

关于不同配色方案的 Matlab 冲浪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11286539/

相关文章:

database - 通过 MATLAB 错误连接到 postgresql 数据库

matlab - 如何打印多个开放图形,如何简化将数据导入 MATLAB

matlab - 如何阻止关闭动画后图形反复弹出

python - 如何将 matlab 代码转换为 python 代码?

visualization - 来自gensim的pyLDAvis可视化未在google colab中显示结果

mongodb - Cubism.js 与 mongodb 和实时数据

javascript - 对于 d3 力导向图,节点、组和值在 JSON 中意味着什么?

mongodb - 对 NoSQL 设计的困惑

matlab - MATLAB 中的特征值

python - Seaborn - 极坐标图 - 如何更改 FacetGrid 中的度数