MATLAB: Change colors for each bins in histogram

histogram bins color

Hi, I have attached sample data, I plot histogram for the sample data as: hist = histogram(sample)
I need to color each bin(group of values) in different, and put annotation text in figure what each color represent :

Best Answer

From R2014b onwards, the only way to do it is to bar() in each entry one at a time, specifying the color you want. Well, you could also use patch() or fill() or rectangle() to put in the bars; the point is that histogram objects do not allow you to change the bar colors individually now.