I have a bivariate histogram plot created using bar3
. I'm trying to change the color of the bars that have a height less than a certain threshold, but to no avail. I got this code:
h = bar3(dataSample, 0.5);
for n=1:numel(h)
cdata=get(h(n),'zdata');
set(h(n),'cdata',cdata,'facecolor','interp')
end
I can't figure out how to make the plot look like the one below, where the bars less than say 0.001 are gray:
Any ideas?
here's how:
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)]);
I've arbitrarily decided to cut the colormap in the middle, first 128 intensities as gray the next 128 intensities in color. you can cut it however you want. You can find the threshold you want by setting the colormap binning (say to 256 bins) and the place in that partition below which it'll be gray.