MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   如何用使用不同颜色图的轮廓图覆盖pcolor图? (https://www.labfans.com/bbs/showthread.php?t=26732)

poster 2019-12-14 20:46

如何用使用不同颜色图的轮廓图覆盖pcolor图?
 
无法实现的最小示例:

[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设置。



[B]回答:[/B]

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

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) [IMG]https://i.stack.imgur.com/oX6G3.png[/IMG]

为了获得更方便的解决方案,您可能还想看看[URL="http://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/"]本周的文件交换精选[/URL]



[url=https://stackoverflow.com/questions/5457723]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:25

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.