MATLAB: How to set the histogram width

histogram width

I would like to set the histogram width in hist(), can anyone help? Thanks

Best Answer

It sounds like what you want to do is return the counts and bin centers from hist(). In other words, do not plot with hist(), rather user bar() to plot. The third input argument to bar() is the bar width.
[N,X] = hist(randn(1000,1));
bar(X,N,0.5)
% the input 0.5 controls the bar width, it defaults to 0.8