Borrar filtros
Borrar filtros

how to remove a bar from histogram which drawn using 'hist' function?

7 visualizaciones (últimos 30 días)
hi can anyone help me to remove zeros bar in histogram this is a part of the code . i'm new in matlab so pleas help me
[hCount, hValues] = hist(h(:), 6);
[sCount, sValues] = hist(s(:), 6);
[vCount, vValues] = hist(v(:), 6);
% Plot histograms.
subplot(3, 4, 6);
bar(hValues, hCount);
title('Hue Histogram');
subplot(3, 4, 7);
bar(sValues, sCount);
title('Saturation Histogram');
subplot(3, 4, 8);
bar(vValues, vCount);
title('Value Histogram');

Respuesta aceptada

Tom Lane
Tom Lane el 22 de Feb. de 2013
If you want to omit zeros from the bar calculations:
hist(h(h~=0), 6)
Depending on your data, this may omit the bar that contains zero.
If you want to omit bars that have zero height, well, when I try this I don't see anything at those spots. Maybe you could explain some more.

Más respuestas (1)

Image Analyst
Image Analyst el 22 de Feb. de 2013
Sometimes your counts have one bar that you want to get rid of, for example the bar for the v bin representing a v value of 0 is so tall that when you display it you can't see the other bars because they're so short. To do that, I typically just set that counts value to zero before plotting.
[vCount, vValues] = hist(v(:), 6);
% Let's say the first bin is way, way taller than the other bins
% so you can't see the shape of the histogram of the other bins.
% You can set the bin = 0
vCount(1) = 0;
% Then plot it
bar(vValues, vCount, 'BarWidth', 1.0);
Alternatively you can take the log of the counts to compress the tall bins:
bar(vValues, log(vCount), 'BarWidth', 1.0);

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by