【问题标题】:How to overlay a pcolor plot with a contour plot that uses a different colormap?如何用使用不同颜色图的等高线图覆盖 pcolor 图?
【发布时间】:2011-03-28 20:00:42
【问题描述】:

没有实现的最小示例:

[X,Y,Z] = peaks;
figure;
pcolor(X,Y,Z);
shading flat;
hold all;
axes;
contour(X,Y,Z);
colormap gray;  % this should only apply to the contour plot axes...
axis off;       % ... but it doesn't

这显示了灰度颜色图中的等高线图和伪彩色图。但是,我想要实现的只是将轮廓变为灰色。

这只是一个极简示例,实际上等值线图是具有不同范围的不同数据,因此还需要两个独立的caxis 设置。

【问题讨论】:

标签: matlab plot contour


【解决方案1】:

您可以通过连接两个颜色图来解决此问题,并确保函数的值能够访问颜色图的正确部分:

cm = [jet(64);gray(64)];
figure,
pcolor(X,Y,Z)
shading flat
hold on
%# Z in the contour starts after the maximum
%# of Z in pcolor
contour(X,Y,Z-min(Z(:))+max(Z(:))+2,'LineWidth',2)
%# apply the colormap
colormap(cm)

为了更方便的解决方案,您可能还想看看this file exchange pick of the week

【讨论】:

  • 谢谢。如果功能范围相差几个数量级,则可能必须小心。我也会看看你链接到的freezeColors
  • @Tobias Kienzler:是的,正确缩放数据/颜色图可能很棘手。此外,如果数据提示未显示正确的值,可能会很烦人。我的解决方案确实是一种解决方法。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-08
  • 2015-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-23
相关资源
最近更新 更多