When z values are 0 with a log ZScale, the plot is rendered incorrectly. That's coherent, because log10(0) = -inf.
Example:
Y = cool(7);
bar3(Y)
set(gca,'ZScale','log')
But how can I remove this 0 bars from the plot?
A solution given by Mathworks (http://www.mathworks.nl/support/solutions/en/data/1-2VFT6X/?product=ML&solution=1-2VFT6X) is the following:
Y = cool(7);
bar3(Y)
set(gca,'ZScale','log')
llim = .1;
h = get(gca,'Children');
for i = 1:length(h)
ZData = get(h(i), 'ZData');
ZData(ZData==0) = llim;
set(h(i), 'ZData', ZData);
end
This solution replaces 0 values by 0.1 (then log10(0.1) = -1) but I want to remove 0 bars, not draw -1 bars.
Also I tried set to NaN all 0 values How to hide zero values in bar3 plot in MATLAB but set ZScale to log does not like it.
Any suggestion?
Thanks in advance
EDIT: The easiest solution that I see is to apply the logarithmic scale manually:
Y = cool(7);
Y = log10(Y);
Y(Y==-inf)=NaN;
bar3(Y)