用单一颜色绘制低于阈值的所有条

Painting all bars less lower than a threshold with a single color

我有一个使用 bar3 创建的双变量直方图。我试图更改高度小于特定阈值的条形的颜色,但无济于事。我得到了这个代码:

h = bar3(dataSample, 0.5);
for n=1:numel(h)
     cdata=get(h(n),'zdata');
     set(h(n),'cdata',cdata,'facecolor','interp')
end

我不知道如何让情节看起来像下面的情节,其中小于 0.001 的条是灰色的:

有什么想法吗?

方法如下:

z=peaks(20);
h=bar3(z) 
for n=1:numel(h)
 cdata=get(h(n),'zdata');
 set(h(n),'cdata',cdata,'facecolor','interp')
end

colormap([0.5.*ones(128,3); parula(128)]);

我随意决定在中间切割颜色图,前 128 种强度为灰色,接下来的 128 种强度为彩色。你可以随便剪。您可以通过设置颜色图分箱(比如 256 个分箱)和该分区中低于其为灰色的位置来找到所需的阈值。