MATLAB: How to display the bin count of each bar at the top of each histogram bar

bin counthistogramMATLAB

I'm using the histogram function to display a histogram. How do I display the bin count of each bar at the top of each histogram bar?

Best Answer

x = randn(10000,1);
h = histogram(x) ;
x = h.BinEdges ;
y = h.Values ;
text(x(1:end-1),y,num2str(y'),'vert','bottom','horiz','center');
box off
Related Question