颜色轮廓与 pcolor 不同
我将 pcolor 与轮廓线一起使用。但是,无法从图中识别线条的值,如下图所示。
[x y data] = peaks(1000);
data = data / max(max(data));
colorDepth = 1000;
colormap(jet(colorDepth));
hold on;
pcolor(x,y,data); shading flat
[C,hfigc] = contour(x, y, data,[0:0.1:1]);
set(hfigc, ...
'LineWidth',1.0, ...
'Color', [1 1 1]);
hold off;
hcb = colorbar('location','EastOutside');
我宁愿希望 pcolor 为灰度值,轮廓线为彩色。然而,我还需要轮廓线的图例。
编辑: 它以某种方式通过组合两个颜色图来工作,但随后颜色条显示两者,这不是我想要的。我宁愿想要一个包含与绘图相同的轮廓线的颜色条。
[x y data] = peaks(1000);
data = data - min(min(data));
data = data / max(max(data));
colorDepth = 1000;
hold on;
caxis([-1 1]);
colormap([gray(colorDepth); jet(colorDepth)]);
hplot = pcolor(x,y,data); shading flat
[C,hfigc] = contour(x, y, data-1,[-1:0.1:0]);
set(hfigc, 'LineWidth',1.0);
% set(hfigc, 'Color', [1 1 1]);
hold off;
hcb = colorbar('location','EastOutside');
编辑: 来校正颜色条
set(hcb, 'Ylim', [0 1]);
可以使用
I am using pcolor together with contour lines. However, the value of the lines can not be identified from the plot, as can be seen in the following picture.
[x y data] = peaks(1000);
data = data / max(max(data));
colorDepth = 1000;
colormap(jet(colorDepth));
hold on;
pcolor(x,y,data); shading flat
[C,hfigc] = contour(x, y, data,[0:0.1:1]);
set(hfigc, ...
'LineWidth',1.0, ...
'Color', [1 1 1]);
hold off;
hcb = colorbar('location','EastOutside');
I would rather want the pcolor to be in gray values and the contour lines in colors. However then I need a legend for the contour lines as well.
EDIT:
It works somehow by combining two colormaps, but then the colorbar shows both, which is not what I want. I would rather want to have a colorbar which includes the same contour lines as the plot.
[x y data] = peaks(1000);
data = data - min(min(data));
data = data / max(max(data));
colorDepth = 1000;
hold on;
caxis([-1 1]);
colormap([gray(colorDepth); jet(colorDepth)]);
hplot = pcolor(x,y,data); shading flat
[C,hfigc] = contour(x, y, data-1,[-1:0.1:0]);
set(hfigc, 'LineWidth',1.0);
% set(hfigc, 'Color', [1 1 1]);
hold off;
hcb = colorbar('location','EastOutside');
EDIT:
The colorbar can be corrected with
set(hcb, 'Ylim', [0 1]);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除了问题中已经提出的解决方案之外,还可以使用工具 freezeColors 和 COLORMAP 和 COLORBAR 实用程序,用于更改单个图中的颜色图
Besides the solution presented already in the question it is possible to use the tools freezeColors and COLORMAP and COLORBAR utilities to change the colormap in a single figure